[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

Guido van Rossum report at bugs.python.org
Wed Nov 11 20:47:23 EST 2015


Guido van Rossum added the comment:

Justin's repro provides a clue: when the event loop is stopped before all
callbacks have been processed, when the loop is restarted the I/O selector
is asked again to do its work, and it will report all the same sockets as
ready. So then the callback will be put into the ready queue again (even
though it's already there). Then the second call will find the future
already done.

I'm not sure how this explains Alexander's issue but it's probably
something similar. We should carefully review the other I/O callbacks too
-- most of them look like they don't mind being called spuriously, but
there are a few others (_sock_recv, _sock_sendall, _sock_accept) that look
like they check for fut.cancelled() and might be susceptible to the same
bug.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25593>
_______________________________________


More information about the Python-bugs-list mailing list