Skip to content

Commit df6ecc0

Browse files
vsajipmiss-islington
authored andcommitted
pythongh-65046: Add note about logging from async code. (pythonGH-97602)
(cherry picked from commit 5c110d1) Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
1 parent 0a7d435 commit df6ecc0

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
@@ -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)