diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2022-09-28 04:17:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 04:17:42 (GMT) |
commit | 5c110d112600b679b4cf41b11d2b73653da60555 (patch) | |
tree | 58fb6d35a1b7ea6ba5a20154c5f5f5618902b885 /Doc/howto | |
parent | d582edf0be9251774722a00456b888ec3793b757 (diff) | |
download | cpython-5c110d112600b679b4cf41b11d2b73653da60555.zip cpython-5c110d112600b679b4cf41b11d2b73653da60555.tar.gz cpython-5c110d112600b679b4cf41b11d2b73653da60555.tar.bz2 |
gh-65046: Add note about logging from async code. (GH-97602)
Diffstat (limited to 'Doc/howto')
-rw-r--r-- | Doc/howto/logging-cookbook.rst | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst index 16df3b7..5b07974 100644 --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -397,6 +397,14 @@ which, when run, will produce: MainThread: Look out! +.. note:: Although the earlier discussion wasn't specifically talking about + async code, but rather about slow logging handlers, it should be noted that + when logging from async code, network and even file handlers could lead to + problems (blocking the event loop) because some logging is done from + :mod:`asyncio` internals. It might be best, if any async code is used in an + application, to use the above approach for logging, so that any blocking code + runs only in the ``QueueListener`` thread. + .. versionchanged:: 3.5 Prior to Python 3.5, the :class:`QueueListener` always passed every message received from the queue to every handler it was initialized with. (This was |