Commit a8923303 authored by Denis Bilenko's avatar Denis Bilenko

use _socket.socket instead of _original_socket

- since _socket is not monkey patched, not need to save stuff from
parent 1acd1e05
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
__all__ = ['GreenSocket', 'GreenFile', 'GreenPipe'] __all__ = ['GreenSocket', 'GreenFile', 'GreenPipe']
import _socket import _socket
_original_socket = _socket.socket _original_socket = _socket.socket # XXX remove it
_original_fromfd = _socket.fromfd _original_fromfd = _socket.fromfd # XXX remove it
_original_socketpair = _socket.socketpair _original_socketpair = _socket.socketpair # XXX remove it
error = _socket.error error = _socket.error
timeout = _socket.timeout timeout = _socket.timeout
__socket__ = __import__('socket') __socket__ = __import__('socket')
...@@ -144,7 +144,7 @@ class GreenSocket(object): ...@@ -144,7 +144,7 @@ class GreenSocket(object):
def __init__(self, family_or_realsock=_socket.AF_INET, *args, **kwargs): def __init__(self, family_or_realsock=_socket.AF_INET, *args, **kwargs):
if isinstance(family_or_realsock, (int, long)): if isinstance(family_or_realsock, (int, long)):
self.fd = _original_socket(family_or_realsock, *args, **kwargs) self.fd = _socket.socket(family_or_realsock, *args, **kwargs)
self.timeout = _socket.getdefaulttimeout() self.timeout = _socket.getdefaulttimeout()
else: else:
if hasattr(family_or_realsock, '_sock'): if hasattr(family_or_realsock, '_sock'):
...@@ -466,12 +466,12 @@ class GreenSSL(GreenSocket): ...@@ -466,12 +466,12 @@ class GreenSSL(GreenSocket):
def socketpair(*args): def socketpair(*args):
one, two = _original_socketpair(*args) one, two = _socket.socketpair(*args)
return GreenSocket(one), GreenSocket(two) return GreenSocket(one), GreenSocket(two)
def fromfd(*args): def fromfd(*args):
return GreenSocket(_original_fromfd(*args)) return GreenSocket(_socket.fromfd(*args))
def socket_bind_and_listen(descriptor, addr=('', 0), backlog=50): def socket_bind_and_listen(descriptor, addr=('', 0), backlog=50):
set_reuse_addr(descriptor) set_reuse_addr(descriptor)
...@@ -513,7 +513,7 @@ def ssl_listener(address, private_key, certificate): ...@@ -513,7 +513,7 @@ def ssl_listener(address, private_key, certificate):
which accepts connections forever and spawns greenlets for which accepts connections forever and spawns greenlets for
each incoming connection. each incoming connection.
""" """
r = _original_socket() r = _socket.socket()
sock = wrap_ssl000(r, private_key, certificate) sock = wrap_ssl000(r, private_key, certificate)
socket_bind_and_listen(sock, address) socket_bind_and_listen(sock, address)
return sock return sock
...@@ -604,7 +604,7 @@ def create_connection_ssl(address, timeout=_GLOBAL_DEFAULT_TIMEOUT): ...@@ -604,7 +604,7 @@ def create_connection_ssl(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
af, socktype, proto, canonname, sa = res af, socktype, proto, canonname, sa = res
sock = None sock = None
try: try:
_sock = _original_socket(af, socktype, proto) _sock = _socket.socket(af, socktype, proto)
sock = wrap_ssl000(_sock) sock = wrap_ssl000(_sock)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT: if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout) sock.settimeout(timeout)
......
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