def __init__( self, sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, *args, **kw ): if not isinstance(sock, GreenSocket): sock = GreenSocket(sock) self.act_non_blocking = sock.act_non_blocking if six.PY2: # On Python 2 SSLSocket constructor queries the timeout, it'd break without # this assignment self._timeout = sock.gettimeout() # nonblocking socket handshaking on connect got disabled so let's pretend it's disabled # even when it's on super(GreenSSLSocket, self).__init__( sock.fd, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect and six.PY2, *args, **kw ) # the superclass initializer trashes the methods so we remove # the local-object versions of them and let the actual class # methods shine through # Note: This for Python 2 try: for fn in orig_socket._delegate_methods: delattr(self, fn) except AttributeError: pass if six.PY3: # Python 3 SSLSocket construction process overwrites the timeout so restore it self._timeout = sock.gettimeout() # it also sets timeout to None internally apparently (tested with 3.4.2) _original_sslsocket.settimeout(self, 0.0) assert _original_sslsocket.gettimeout(self) == 0.0 # see note above about handshaking self.do_handshake_on_connect = do_handshake_on_connect if do_handshake_on_connect and self._connected: self.do_handshake()
def __init__(self, sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, *args, **kw): if not isinstance(sock, GreenSocket): sock = GreenSocket(sock) self.act_non_blocking = sock.act_non_blocking if six.PY2: # On Python 2 SSLSocket constructor queries the timeout, it'd break without # this assignment self._timeout = sock.gettimeout() # nonblocking socket handshaking on connect got disabled so let's pretend it's disabled # even when it's on super(GreenSSLSocket, self).__init__(sock.fd, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect and six.PY2, *args, **kw) # the superclass initializer trashes the methods so we remove # the local-object versions of them and let the actual class # methods shine through # Note: This for Python 2 try: for fn in orig_socket._delegate_methods: delattr(self, fn) except AttributeError: pass if six.PY3: # Python 3 SSLSocket construction process overwrites the timeout so restore it self._timeout = sock.gettimeout() # it also sets timeout to None internally apparently (tested with 3.4.2) _original_sslsocket.settimeout(self, 0.0) assert _original_sslsocket.gettimeout(self) == 0.0 # see note above about handshaking self.do_handshake_on_connect = do_handshake_on_connect if do_handshake_on_connect and self._connected: self.do_handshake()
def __init__(self, sock, *args, **kw): if not isinstance(sock, GreenSocket): sock = GreenSocket(sock) self.act_non_blocking = sock.act_non_blocking self._timeout = sock.gettimeout() super(GreenSSLSocket, self).__init__(sock.fd, *args, **kw) # the superclass initializer trashes the methods so... for fn in orig_socket._delegate_methods: delattr(self, fn)
def __init__(self, sock, *args, **kw): if not isinstance(sock, GreenSocket): sock = GreenSocket(sock) self.act_non_blocking = sock.act_non_blocking self._timeout = sock.gettimeout() super(GreenSSLSocket, self).__init__(sock.fd, *args, **kw) # the superclass initializer trashes the methods so we remove # the local-object versions of them and let the actual class # methods shine through try: for fn in orig_socket._delegate_methods: delattr(self, fn) except AttributeError: pass