Commit 6748a541 authored by Denis Bilenko's avatar Denis Bilenko

monkey: only patch socketpair and fromfd if they exist

parent 635a2372
...@@ -61,10 +61,12 @@ def patch_thread(threading=True, _threading_local=True): ...@@ -61,10 +61,12 @@ def patch_thread(threading=True, _threading_local=True):
def patch_socket(dns=True, aggressive=True): def patch_socket(dns=True, aggressive=True):
from gevent.socket import socket, fromfd, socketpair, SocketType from gevent.socket import socket, fromfd, socketpair, SocketType
_socket = __import__('socket') _socket = __import__('socket')
_socket.socket = socket _socket.socket = socket.socket
_socket.fromfd = fromfd _socket.SocketType = socket.SocketType
_socket.socketpair = socketpair if hasattr(socket, 'socketpair'):
_socket.SocketType = SocketType _socket.socketpair = socket.socketpair
if hasattr(socket, 'fromfd'):
_socket.fromfd = socket.fromfd
try: try:
from gevent.socket import ssl, sslerror from gevent.socket import ssl, sslerror
_socket.ssl = ssl _socket.ssl = ssl
......
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