deliberate versus os socket timeout

Robin Becker robin at
Fri Jul 6 12:46:56 CEST 2007

John J. Lee wrote:
> What do you mean "is in fact true"?  Is what true?  That the reason is
> always formatted in those ways when those particular errors occur?
> Not sure there's any reason to rely on that: I'd expect .reason to be
> an exception object, so (reading the docs for module socket)
> e.reason.args[0] should be the error code if one is available, in this
> case errno.ETIMEDOUT (i.e. WSAETIMEDOUT, which means the timeout
> occurred before a connection was established).  Sometimes
> e.reason.args will be length-1, and e.reason.args[0] will be a string,
> again according to the docs for module socket.

well I suspect there's a whole twisty maze of stuff to do to reliably detect 
whether a timeout was deliberate or not so I'll pass on that.

>> More importantly is there anything I can do to avoid these wrong os
>> inspired timeouts? I'm just using urllib2 to read from a remote site
> [...]
> Please define "wrong" ;-)

well if I ask to be timed out after 120 seconds I don't expect a timeout error 
after 20 so I would define the 20 second case to be somehow wrong or unexpected.

> Googling suggests Windows doesn't let you configure its connect
> timeout, except through a registry setting:

the implication of windows providing its own timeout seems to make the socket 
defaulttimeout irrelevant since I can have no per socket control over it. I 
think this came up before and I just forgot about it mumble mumble
Robin Becker

More information about the Python-list mailing list