ssl problems with gevent 1.0.1 & python 2.7.9

464 views
Skip to first unread message

Ido

unread,
Mar 29, 2015, 11:05:17 AM3/29/15
to gev...@googlegroups.com
Hi,

I'm running gevent 1.0.1 and python 2.7.9.

When I call:
conn = ssl_context.wrap_socket(socket.socket(socket.AF_INET), server_hostname=HOST)

I get an error in ssl.py:

Traceback (most recent call last):
  File "./client.py", line 34, in <module>
    use_ssl()
  File "./client.py", line 25, in use_ssl
    server_hostname=HOST)
  File "/home/ido/pybase/2.7.9/usr/local/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
TypeError: __init__() got an unexpected keyword argument '_context'

and sometimes this one:
Traceback (most recent call last):
  File "./client.py", line 34, in <module>
    use_ssl()
  File "./client.py", line 25, in use_ssl
    server_hostname=HOST)
  File "/home/ido/pybase/2.7.9/usr/local/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
TypeError: __init__() got an unexpected keyword argument 'server_hostname'

Without gevent, my code works, but then it's not in non-blocking mode. :)

I tried looking online for an answer, and it looks like a few other people ran into this problem as well, but w/o a working solution.

My guess is that gevent 1.0.1 is designed to work with python <= 2.7.8, and when the ssl module in python 2.7.9 was migrated from python 3, gevent stopped working.

I figure one solution is to move over to python 3... Unfortunately, a large code-base and dependencies may make this a no-go for me right now...

Has anyone else ran into this?  Any patches out there (or coming)? Am I doing something completely wrong here? :)

Thanks,
Ido

Jonathan Kamens

unread,
Mar 29, 2015, 12:47:45 PM3/29/15
to gev...@googlegroups.com
We encountered this problem at Quantopian, and I managed to cobble together a working version in https://github.com/quantopian/gevent/tree/ssl2_SSLSocket_arguments, which to give credit where credit is due is based on https://github.com/Eugeny/gevent. You're welcome to give our branch a try and see if it works for you. I recommend cloning it, so that you've got a copy of your own even if we end up going in a different direction later and remove it.

I haven't submitted a PR to https://github.com/gevent/gevent, because (a) I didn't really put the effort into ensuring that our fixes are 100% copacetic, Pythonic, ready to be merged into master, etc.; I just got it far enough to make it work, and that was good enough; and (b) it's not clear that the original maintainers of gevent are actively maintaining it anymore, so it's not clear that it's worth the effort to put together a PR.

There's also https://github.com/fantix/gevent, which I haven't looked at closely but which I believe is an effort to make gevent compatible with python3. I don't know whether they preserved python2 compatibility on that branch, and if so, whether they may have addressed the 2.7.9 issue.

Regards,

  jik
--
You received this message because you are subscribed to the Google Groups "gevent: coroutine-based Python network library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gevent+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ido

unread,
Apr 1, 2015, 5:09:54 AM4/1/15
to gev...@googlegroups.com
Thanks, Jonathan, I'll definitely check out your work on this!
Reply all
Reply to author
Forward
0 new messages