[Python-Dev] Socket timeout and completion based sockets
Kristján Valur Jónsson
kristjan at ccpgames.com
Mon Nov 26 12:49:39 CET 2012
Regarding the recent discussion on python-ideas about asyncronous IO, I'd like to ask a question about python socket's Timeout feature.
Specifically this: Is it a documented or a guaranteed feature that a send/receive operation that times out with a socket.timeout error is re-startable on that socket?
The reason I ask is that depending on the implementation, a timeout may leave a socket in an undefined state.
As it is implemented in the standard cPython implementation, the timeout feature is done with an internal select() call. Thus, if the select() call times out, socket send/receive is not even called, so a retry is possible without issue.
However, other implementations of python sockets, e.g. ones that rely on IO completion, may not have the luxury of using select. For example, on Windows, there is no way to abort an IOCP socket call, so a timeout must be implemented by aborting the wait. Dealing with the resulting race can be an interesting challenge.
K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121126/d2a661ba/attachment.html>
More information about the Python-Dev
mailing list