Why I Stopped Coding and Why I'd Start Again
Subject:   I too am baffled by the fanboys
Date:   2008-02-19 11:46:41
From:   khiltd
I'm finding that Python's sockets library is also a good deal less flexible than PHP's or Ruby's, which is odd considering its age. The default timeout on a blocking socket is "None" which, in my testing, roughly equates to about 10 minutes. That's 10 minutes your script is going to sit there doing absolutely nothing before it throws an exception because the port you're trying to connect to is blocked somewhere or because the server is down.

Now the socket object has a handy-dandy settimeout method, but passing it a more sensible value than "None" causes it to become non-blocking. This means you have to introduce all kinds of ridiculous asynchronous polling cruft in order to accomplish something that should be an incredibly straightforward task in any other language. I don't know about anybody else, but multi-threading a web app is not my idea of a good time.

To get a sensible timeout on a blocking socket you have to call the class method socket.setdefaulttimeout() which sets the default timeout value for ALL socket objects, and what's worse, it does not return the previous default value for easy restoration; you have to make a separate call to socket.getdefaulttimeout() if you want that.

15 years and this is the best "battery" they could come up with to "include" in the package?