mirror of
https://github.com/python/cpython.git
synced 2025-10-27 16:57:08 +00:00
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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| __main__.py | ||
| echo.py | ||
| echo2.py | ||
| echo3.py | ||
| keycert3.pem | ||
| pycacert.pem | ||
| ssl_cert.pem | ||
| ssl_key.pem | ||
| test_base_events.py | ||
| test_events.py | ||
| test_futures.py | ||
| test_locks.py | ||
| test_proactor_events.py | ||
| test_queues.py | ||
| test_selector_events.py | ||
| test_streams.py | ||
| test_subprocess.py | ||
| test_tasks.py | ||
| test_transports.py | ||
| test_unix_events.py | ||
| test_windows_events.py | ||
| test_windows_utils.py | ||