コード例 #1
0
class TimeoutHTTP(HTTPConnection):
    """A custom http connection object that supports socket timeout."""
    def __init__(self, host, port=None, timeout=20):
        HTTPConnection.__init__(self, host, port)
        self.timeout = timeout

    def connect(self):
        self.sock = TimeoutSocket(self.timeout)
        self.sock.connect((self.host, self.port))
コード例 #2
0
 def connect(self):
     sock = TimeoutSocket(self.timeout)
     sock.connect((self.host, self.port))
     realsock = getattr(sock.sock, '_sock', sock.sock)
     ssl = socket.ssl(realsock, self.key_file, self.cert_file)
     self.sock = httplib.FakeSocket(sock, ssl)