[Python-Dev] stdlib socket usage and "keepalive"
Antoine Pitrou
solipsis at pitrou.net
Tue Apr 13 00:47:55 CEST 2010
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).
> 1. All "client" libraries should create sockets with the "KEEPALIVE" option.
>
> 2. Modify the socket C module to create all sockets as "Keepalive" by
> default.
I don't know whether there are any negative implications of such solutions.
Granted, the first one is less radical than the second (because servers wouldn't
be impacted).
> 4. 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.
Regards
Antoine.
More information about the Python-Dev
mailing list