Skip to content

Commit 8de3533

Browse files
miss-islingtonpablogsal
authored andcommitted
[3.11] gh-65046: Add note about logging from async code. (GH-97602) (GH-97608)
1 parent edc3356 commit 8de3533

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,14 @@ which, when run, will produce:
604604
605605
MainThread: Look out!
606606
607+
.. note:: Although the earlier discussion wasn't specifically talking about
608+
async code, but rather about slow logging handlers, it should be noted that
609+
when logging from async code, network and even file handlers could lead to
610+
problems (blocking the event loop) because some logging is done from
611+
:mod:`asyncio` internals. It might be best, if any async code is used in an
612+
application, to use the above approach for logging, so that any blocking code
613+
runs only in the ``QueueListener`` thread.
614+
607615
.. versionchanged:: 3.5
608616
Prior to Python 3.5, the :class:`QueueListener` always passed every message
609617
received from the queue to every handler it was initialized with. (This was

0 commit comments

Comments
 (0)