-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions raised by EventLoop.call_soon_threadsafe #83832
Comments
Proactor and selector event loops behave differently when call_soon_threadsafe races with a concurrent call to loop.close(). In a selector event loop, call_soon_threadsafe will either succeed or raise a RuntimeError("Event loop is closed"). In a proactor event loop, it could raise this RuntimeError, but it can also raise an AttributeError due to an unguarded access to self._csock. cpython/Lib/asyncio/proactor_events.py Lines 785 to 787 in 1ed6161
Comments in BaseSelectorEventLoop._write_to_self indicate that this is deliberate, so the cpython/Lib/asyncio/selector_events.py Lines 129 to 136 in 1ed6161
I'd also accept an answer that the exact behavior of this race is undefined and it's up to the application to either arrange for all calls to call_soon_threadsafe to stop before closing the loop. However, I've had users of Tornado argue that they use the equivalent of call_soon_threadsafe in contexts where this coordination would be difficult, and I've decided that tornado's version of this method would never raise, even if there is a concurrent close. So if asyncio declines to specify which exceptions are allowed in this case, tornado will need to add a blanket `except Exception:` around calls to call_soon_threadsafe. |
Good catch. We should fix this for Python 3.8.3. |
Is this related to bpo-39010 too? |
No, this is unrelated to bpo-39010. |
This sadly missed 3.8.3 but I want this addressed for 3.8.4. |
We have trouble finding a Windows expert with available time to address this :/ This is missing 3.8.4 as well. |
Thanks for the bug report Ben Darnell, it's now fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: