Commit 7507e866 authored by Denis Bilenko's avatar Denis Bilenko

monkey: do not break ssl's wrap_socket with socket.ssl

parent 8d777efd
...@@ -55,11 +55,23 @@ def patch_dns(): ...@@ -55,11 +55,23 @@ def patch_dns():
_socket.getaddrinfo = getaddrinfo _socket.getaddrinfo = getaddrinfo
_socket.gethostbyname = gethostbyname _socket.gethostbyname = gethostbyname
def __wrap_socket(sock, keyfile=None, certfile=None, **kwargs):
if kwargs:
ssl = __import__('ssl')
# XXX since there is no gevent.ssl yet, cowardly call the blocking function
return ssl.wrap_socket(sock, keyfile=keyfile, certfile=certfile, **kwargs)
from gevent.socket import ssl
return ssl(sock, keyfile=keyfile, certfile=certfile)
def patch_ssl(): def patch_ssl():
if sys.version_info[:2] >= (2, 6): try:
from gevent.socket import wrap_ssl ssl = __import__('ssl')
import ssl ssl.wrap_socket = __wrap_socket
ssl.wrap_socket = wrap_ssl except ImportError:
pass
def patch_select(): def patch_select():
from gevent.select import select from gevent.select import select
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment