Skip to content

[3.10] gh-65046: Add note about logging from async code. (GH-97602) (GH-97609) #97609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down