Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrap_socket() got an unexpected keyword argument '_context' and deserialize(error)

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'
like image 742
yuut007 Avatar asked Aug 29 '19 14:08

yuut007


2 Answers

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

like image 148
Max Avatar answered Nov 11 '22 13:11

Max


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

like image 33
Evgeni Shudzel Avatar answered Nov 11 '22 14:11

Evgeni Shudzel