This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xlash
Recipients xlash
Date 2008-01-22.15:57:54
SpamBayes Score 0.25312904
Marked as misclassified No
Message-id <1201017477.23.0.0342238589364.issue1907@psf.upfronthosting.co.za>
In-reply-to
Content
The httplib file wasn'T supporting a timeout feature which was essential
for my load testing application I built. In order to do that, I had to
append a parameter to the connect function, which takes a socket timeout
value integer in seconds.

    def connect(self,timeout=None):
        """Connect to the host and port specified in __init__."""
        msg = "getaddrinfo returns an empty list"
        for res in socket.getaddrinfo(self.host, self.port, 0,
                                      socket.SOCK_STREAM):
            af, socktype, proto, canonname, sa = res
            try:
                self.sock = socket.socket(af, socktype, proto)
		#Guillaume's timeout
		self.sock.settimeout(timeout)
                if self.debuglevel > 0:
                    print "connect: (%s, %s)" % (self.host, self.port)
                self.sock.connect(sa)
            except socket.error, msg:
                if self.debuglevel > 0:
                    print 'connect fail:', (self.host, self.port)
                if self.sock:
                    self.sock.close()
                self.sock = None
                continue
            break
        if not self.sock:
            raise socket.error, msg

Simple patch, but it was essential for my work.
History
Date User Action Args
2008-01-22 15:57:57xlashsetspambayes_score: 0.253129 -> 0.25312904
recipients: + xlash
2008-01-22 15:57:57xlashsetspambayes_score: 0.253129 -> 0.253129
messageid: <1201017477.23.0.0342238589364.issue1907@psf.upfronthosting.co.za>
2008-01-22 15:57:55xlashlinkissue1907 messages
2008-01-22 15:57:54xlashcreate