gh-65046: Add note about logging from async code. (GH-97602)

This commit is contained in:
Vinay Sajip 2022-09-28 05:17:42 +01:00 committed by GitHub
parent d582edf0be
commit 5c110d1126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

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