Am I misusing socket.setdefaulttimeout here?
skip at pobox.com
Thu Mar 20 23:37:25 CET 2003
Syver> I was under the definite impression that timeoutsocket also
Syver> worked by putting the socket in blocking mode.
You meant non-blocking mode, yes?
Syver> And httplib doesn't use the file interface to the socket library
Syver> as far as I can remember.
def __init__(self, sock, debuglevel=0, strict=0):
self.fp = sock.makefile('rb', 0)
# Initialize with Simple-Response defaults
line = self.fp.readline()
def read(self, amt=None):
if self.fp is None:
if amt is None:
# unbounded read
s = self.fp.read()
s = self._safe_read(self.length)
self.close() # we read everything
Need I continue? ;-)
Syver> The point I am trying to make here is that I don't see why things
Syver> that worked with timeoutsocker should stop working on the new
Syver> socket with timeout mode.
Timeoutsocket implements a file-like abstraction (TimeoutFile) directly on
top of the socket without calling the socket's makefile method. It
implements write, read, readline, readlines and flush methods. I suspect
this would work for the socket module as well, though there are probably
some subtle semantic differences between how TimeoutFile the file-like
objects returned by sock.makefile operate.
More information about the Python-list