cpython/Lib/asyncio
Victor Stinner de993bd9b6 (Merge 3.4) asyncio, Tulip issue 205: Fix a race condition in
BaseSelectorEventLoop.sock_connect()

There is a race condition in create_connection() used with wait_for() to have a
timeout. sock_connect() registers the file descriptor of the socket to be
notified of write event (if connect() raises BlockingIOError). When
create_connection() is cancelled with a TimeoutError, sock_connect() coroutine
gets the exception, but it doesn't unregister the file descriptor for write
event. create_connection() gets the TimeoutError and closes the socket.

If you call again create_connection(), the new socket will likely gets the same
file descriptor, which is still registered in the selector. When sock_connect()
calls add_writer(), it tries to modify the entry instead of creating a new one.

This issue was originally reported in the Trollius project, but the bug comes
from Tulip in fact (Trollius is based on Tulip):
https://bitbucket.org/enovance/trollius/issue/15/after-timeouterror-on-wait_for

This change fixes the race condition. It also makes sock_connect() more
reliable (and portable) is sock.connect() raises an InterruptedError.
2014-08-31 15:08:21 +02:00
..
__init__.py Fix asyncio.__all__: export also unix_events and windows_events symbols 2014-07-18 12:44:25 +02:00
base_events.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
base_subprocess.py asyncio: sync with Tulip 2014-07-14 18:33:40 +02:00
constants.py asyncio: Pause accepting whenever accept() returns certain errors. Fixes asyncio issue #78. 2013-11-01 14:12:50 -07:00
coroutines.py asyncio: sync with Tulip 2014-07-11 01:04:16 +02:00
events.py asyncio: sync with Tulip 2014-07-29 12:58:23 +02:00
futures.py asyncio: sync with Tulip 2014-07-29 12:58:23 +02:00
locks.py Accept optional lock object in Condition ctor (tulip issue #198) 2014-07-26 17:54:34 +03:00
log.py
proactor_events.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
protocols.py asyncio: Fix spelling and typos. 2014-02-18 22:27:48 -05:00
queues.py Closes #21886, #21447: Fix a race condition in asyncio when setting the result 2014-07-05 15:29:41 +02:00
selector_events.py asyncio, Tulip issue 205: Fix a race condition in BaseSelectorEventLoop.sock_connect() 2014-08-31 15:07:57 +02:00
streams.py asyncio, tulip issue 193: Convert StreamWriter.drain() to a classic coroutine 2014-07-22 12:03:40 +02:00
subprocess.py asyncio, tulip issue 190: Process.communicate() now ignores 2014-07-17 13:12:03 +02:00
tasks.py asyncio, Tulip issue 201: Fix a race condition in wait_for() 2014-08-28 11:19:25 +02:00
test_utils.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
transports.py asyncio, tulip issue 203: Add _FlowControlMixin.get_write_buffer_limits() method 2014-08-26 00:22:28 +02:00
unix_events.py (Merge 3.4) asyncio: sync with Tulip 2014-08-25 23:22:54 +02:00
windows_events.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
windows_utils.py Issue #21119: asyncio: Make sure that socketpair() close sockets on error 2014-06-04 00:12:28 +02:00