On Sat, 29 Mar 2008 08:18:23 -0300, Guilherme Polo wrote: >I don't know why you think timeout is forbidden too, it is not.
I can't tell for sure whether it is or isn't, because of this language in the socket module docs: "s.settimeout(0.0) is equivalent to s.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1)." >>I wanted to use file-like objects with socket timeouts, so I ended up >>writing my own replacement for socket._fileobject. I'd appreciate it >>if someone could either explain to me why my new class was unnecessary, >>or else encourage me to contribute it as a patch to the socket module. > >It looks like to be unnecessary. I'm hoping for a more definitive answer than "looks like", but thank you just the same. My main concern is this: A brief look at the existing socket._fileobject shows that its read() method calls recv() in a loop, appending to a temporary buffer on each pass, and finally returning the buffer when recv() gets no more data. It looks to me like a socket timeout exception would cause that loop to exit without saving the data collected in earlier passes. In other words, data loss on recv() timeout. If someone more familiar with socket._fileobject can point out a reason this cannot happen (perhaps I've missed something) I'll be satisfied. Otherwise, I think my rewritten class has value. -- http://mail.python.org/mailman/listinfo/python-list