-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/13/2010 12:47 AM, Antoine Pitrou wrote:
Jesus Cea <jcea <at> jcea.es> writes:
PS: "socket.setdefaulttimeout()" is not enough, because it could shutdown a perfectly functional connection, just because it was idle for too long.
The socket timeout doesn't shutdown anything. It just puts a limit on how much time recv() and send() can block. Then it's up to you to detect whether the server is still alive (for example by pinging it through whatever means the application protocol gives you).
A regular standard library (let say, poplib) would abort, after getting the timeout exception.
- Modify client libraries to accept a new optional socket-like object
as an optional parameter. This would allow things like transparent compression or encryption, or to replace the socket connection by anything else (read/write to shared memory or database, for example).
This could be useful too.
I have been thinking about this for years. Do you actually think this could be formally proposed?.
What bugs me is that the socket creation is deep inside the stdlibs. You can not control it easily (I have overloaded socket.socket() in the past for controlling the number of concurrent connections to servers, for instance, or providing encryption), and it is difficult to test.
If these stdlib methods could accept an optional parameter instead of creating the socket internally, test is trivial, and you can reuse the lib to access the service via an arbitrary object (this weekend I just tunneled TCP/IP via DNS requests/answers, shame on you, airport wifi hotspots!).
- -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ email@example.com - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:firstname.lastname@example.org _/_/ _/_/ _/_/_/_/_/ . _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz