[issue21447] Intermittent asyncio.open_connection / futures.InvalidStateError
Guido van Rossum
report at bugs.python.org
Tue May 6 22:53:53 CEST 2014
Guido van Rossum added the comment:
The second error is easy to explain and fix: it's a race condition between the OS thread used to call getaddrinfo() and the main thread. The method _write_to_self() in selector_events.py is hopelessly naive. It should probably become something like this:
def _write_to_self(self):
csock = self._csock
if csock is not None:
try:
self._csock.send(b'x')
except OSError:
pass
It is possible that the main thread closes csock at any time, and calling send() on a closed socket will raise OSError with errno=9 (EBADF). Fortunately this is because close() sets the fd to -1; so there is no worry about reuse of the fd.
I will investigate the first traceback next.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21447>
_______________________________________
More information about the Python-bugs-list
mailing list