X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fxmlrpcprotocol.py;h=25e7b76d7e2ca7c90e6d23d7aef87d72ade30ed1;hb=1d65bf6101012239a3aa89117dda339d6389ebfa;hp=9232e07f90bc0a717901802ebfc6be02d8bf59eb;hpb=cd6e015ba7142a4fca587841dca25b73d254a7f5;p=sfa.git diff --git a/sfa/util/xmlrpcprotocol.py b/sfa/util/xmlrpcprotocol.py index 9232e07f..25e7b76d 100644 --- a/sfa/util/xmlrpcprotocol.py +++ b/sfa/util/xmlrpcprotocol.py @@ -55,6 +55,20 @@ class XMLRPCTransport(xmlrpclib.Transport): 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(float(self.timeout)) + return conn def getparser(self):