Fix test_socket by properly wrapping socketpair and fromfd in the eventlet.green.socket module.
This commit is contained in:
@@ -5,6 +5,7 @@ _fileobject = __socket._fileobject
|
|||||||
|
|
||||||
from eventlet.api import get_hub
|
from eventlet.api import get_hub
|
||||||
from eventlet.greenio import GreenSocket as socket, GreenSSL as _GreenSSL
|
from eventlet.greenio import GreenSocket as socket, GreenSSL as _GreenSSL
|
||||||
|
from eventlet.greenio import socketpair, fromfd
|
||||||
|
|
||||||
def fromfd(*args):
|
def fromfd(*args):
|
||||||
return socket(__socket.fromfd(*args))
|
return socket(__socket.fromfd(*args))
|
||||||
@@ -33,16 +34,6 @@ def _gethostbyname_tpool(name):
|
|||||||
# XXX there're few more blocking functions in socket
|
# XXX there're few more blocking functions in socket
|
||||||
# XXX having a hub-independent way to access thread pool would be nice
|
# XXX having a hub-independent way to access thread pool would be nice
|
||||||
|
|
||||||
def socketpair(family=None, type=SOCK_STREAM, proto=0):
|
|
||||||
if family is None:
|
|
||||||
try:
|
|
||||||
family = AF_UNIX
|
|
||||||
except AttributeError:
|
|
||||||
family = AF_INET
|
|
||||||
|
|
||||||
a, b = __socket.socketpair(family, type, proto)
|
|
||||||
return socket(a), socket(b)
|
|
||||||
|
|
||||||
|
|
||||||
_GLOBAL_DEFAULT_TIMEOUT = object()
|
_GLOBAL_DEFAULT_TIMEOUT = object()
|
||||||
|
|
||||||
|
@@ -547,3 +547,13 @@ class GreenSSL(GreenSocket):
|
|||||||
def issuer(self):
|
def issuer(self):
|
||||||
return self.fd.issuer()
|
return self.fd.issuer()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def socketpair(*args):
|
||||||
|
one, two = socket.socketpair(*args)
|
||||||
|
return GreenSocket(one), GreenSocket(two)
|
||||||
|
|
||||||
|
|
||||||
|
def fromfd(*args):
|
||||||
|
return GreenSocket(socket.fromfd(*args))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user