X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fxmlrpcprotocol.py;h=0c07accd67f41ddf1d9c635c8d096c018b0e4b41;hb=a447972b567c5d89bb811be6f2b3cccb0d9ce7a8;hp=9232e07f90bc0a717901802ebfc6be02d8bf59eb;hpb=afa6374e8282d841afd1f2415209d4f8307dfe26;p=sfa.git diff --git a/sfa/util/xmlrpcprotocol.py b/sfa/util/xmlrpcprotocol.py index 9232e07f..0c07accd 100644 --- a/sfa/util/xmlrpcprotocol.py +++ b/sfa/util/xmlrpcprotocol.py @@ -49,12 +49,29 @@ class XMLRPCTransport(xmlrpclib.Transport): #conn = HTTPSConnection(host, None, key_file=self.key_file, cert_file=self.cert_file, timeout=self.timeout) #**(x509 or {})) conn = HTTPSConnection(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {})) else: - #conn = HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file, timeout=self.timeout) #**(x509 or {})) - conn = HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {})) + try: + conn = HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file, timeout=self.timeout) #**(x509 or {})) + except TypeError: + # some versions don't have a timeout argument + conn = HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {})) if hasattr(conn, 'set_timeout'): conn.set_timeout(self.timeout) + # Some logic to deal with timeouts. It appears that some (or all) versions + # of python don't set the timeout after the socket is created. We'll do it + # ourselves by forcing the connection to connect, finding the socket, and + # calling settimeout() on it. (tested with python 2.6) + if self.timeout: + if hasattr(conn, "_conn"): + # HTTPS is a wrapper around HTTPSConnection + real_conn = conn._conn + else: + real_conn = conn + conn.connect() + if hasattr(real_conn, "sock") and hasattr(real_conn.sock, "settimeout"): + real_conn.sock.settimeout(self.timeout) + return conn def getparser(self):