Skip to content

Commit feb4be1

Browse files
[3.10] gh-65046: Add note about logging from async code. (GH-97602) (GH-97609)
1 parent 0a7d435 commit feb4be1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/howto/logging-cookbook.rst

+8
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ which, when run, will produce:
397397
398398
MainThread: Look out!
399399
400+
.. note:: Although the earlier discussion wasn't specifically talking about
401+
async code, but rather about slow logging handlers, it should be noted that
402+
when logging from async code, network and even file handlers could lead to
403+
problems (blocking the event loop) because some logging is done from
404+
:mod:`asyncio` internals. It might be best, if any async code is used in an
405+
application, to use the above approach for logging, so that any blocking code
406+
runs only in the ``QueueListener`` thread.
407+
400408
.. versionchanged:: 3.5
401409
Prior to Python 3.5, the :class:`QueueListener` always passed every message
402410
received from the queue to every handler it was initialized with. (This was

0 commit comments

Comments
 (0)