Message396523
`loop.call_soon_threadsafe` raises `RuntimeError` when the event loop has been closed, but that fact doesn't seem to be documented. It would be useful to document it so that that it's clear that that behaviour is part of the API, and can be depended on.
Doc link: I'm looking at https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_soon_threadsafe
My use-case is that I have a background thread that's making use of `loop.call_soon_threadsafe` to place callbacks onto the main thread's event loop. The main thread at some point closes that event loop (e.g., as part of controlled application shutdown, or in the tearDown of a unit test). The background thread isn't in a position to know whether the event loop has been closed or not, and obviously checking that using the `is_closed` attribute runs into race condition issues. So I'd like to catch the potential exception from the `loop.call_soon_threadsafe`, but to do that I need to know what exception type to catch.
It would probably also make sense to document the failure mode for `loop.call_soon`. |
|
Date |
User |
Action |
Args |
2021-06-25 12:00:15 | mark.dickinson | set | recipients:
+ mark.dickinson, asvetlov, docs@python, yselivanov |
2021-06-25 12:00:15 | mark.dickinson | set | messageid: <1624622415.86.0.725571040455.issue44508@roundup.psfhosted.org> |
2021-06-25 12:00:15 | mark.dickinson | link | issue44508 messages |
2021-06-25 12:00:15 | mark.dickinson | create | |
|