I try to use requests to get a url of file. It works well locally but it doesn't work with nameko.
I tried 3 libs of python3.7. But all has the same error. import urllib.request,urllib3,requests
it works well locally like this:
import requests
url = "https://www.python.org/static/img/python-logo.png"
r = requests.get(url)
print(r.content)
But it can't work with nameko:
import requests
from nameko.web.handlers import http
@http("POST", "/import")
def testurl(self,request):
url = "https://www.python.org/static/img/python-logo.png"
r = requests.get(url)
print(r.content)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/nameko/rpc.py", line 373, in __call__
return reply.result()
File "/usr/local/lib/python3.7/site-packages/nameko/rpc.py", line 331, in result
raise deserialize(error)
nameko.exceptions.RemoteError: Exception Error on testurl: Cause : wrap_socket() got an unexpected keyword argument '_context'
It is an eventlet bug. If it is possible you need to downgrade to Python 3.6.
https://github.com/eventlet/eventlet/issues/526
Nameko has a PR for this issue which is on pause until the above is fixed.
https://github.com/nameko/nameko/pull/644
I caught the same error with python 3.7, eventlet 0.25.2, requests 2.24.0. It works fine with requests 2.23.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With