[Python-Dev] Socket timeout and completion based sockets

Guido van Rossum guido at python.org
Mon Nov 26 16:59:08 CET 2012

If you're talking about the standard socket module, I'm not aware that
it uses IOCP on Windows. Are you asking this just in the abstract, or
do you know of a Python implementation that uses IOCP to implement the
standard socket type?

As to the design of the async I/O library (which I am still working
on!), I cannot guarantee anything, and the issue will probably be moot
-- the API won't have the same kind of timeout as the current socket
object (it will have other ways to set deadlines though).

Confusedly yours,


On Mon, Nov 26, 2012 at 3:49 AM, Kristján Valur Jónsson
<kristjan at ccpgames.com> wrote:
> 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
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/guido%40python.org

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list