cpython/Lib/test/test_asyncio
Victor Stinner d5aeccf976 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:07:57 +02:00
..
__init__.py Issue #22002: Make full use of test discovery in test sub-packages. 2014-07-23 12:00:29 -05:00
__main__.py Issue #22002: Make full use of test discovery in test sub-packages. 2014-07-23 12:00:29 -05:00
echo.py
echo2.py
echo3.py
keycert3.pem
pycacert.pem
ssl_cert.pem
ssl_key.pem
test_base_events.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
test_events.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
test_futures.py asyncio: sync with Tulip 2014-07-29 12:58:23 +02:00
test_locks.py asyncio: sync with Tulip 2014-07-29 12:58:23 +02:00
test_proactor_events.py Python issue #21645, Tulip issue 192: Rewrite signal handling 2014-07-17 22:43:40 +02:00
test_queues.py Issue #21163, asyncio: Fix some "Task was destroyed but it is pending!" logs in tests 2014-06-25 23:11:21 +02:00
test_selector_events.py asyncio, Tulip issue 205: Fix a race condition in BaseSelectorEventLoop.sock_connect() 2014-08-31 15:07:57 +02:00
test_streams.py asyncio: Refactor tests: add a base TestCase class 2014-06-18 01:36:32 +02:00
test_subprocess.py asyncio: sync with Tulip 2014-08-25 23:20:52 +02:00
test_tasks.py asyncio, Tulip issue 201: Fix a race condition in wait_for() 2014-08-28 11:19:25 +02:00
test_transports.py asyncio, tulip issue 203: Add _FlowControlMixin.get_write_buffer_limits() method 2014-08-26 00:22:28 +02:00
test_unix_events.py asyncio: Use the new os.set_blocking() function of Python 3.5 if available 2014-07-29 23:08:00 +02:00
test_windows_events.py asyncio: sync with Tulip 2014-07-25 00:54:53 +02:00
test_windows_utils.py Fix asyncio tests on Windows: wait for the subprocess exit 2014-06-04 00:42:04 +02:00