This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients asvetlov, docs@python, mark.dickinson, yselivanov
Date 2021-06-25.12:00:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
`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

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:15mark.dickinsonsetrecipients: + mark.dickinson, asvetlov, docs@python, yselivanov
2021-06-25 12:00:15mark.dickinsonsetmessageid: <>
2021-06-25 12:00:15mark.dickinsonlinkissue44508 messages
2021-06-25 12:00:15mark.dickinsoncreate