]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-65046: Add note about logging from async code. (GH-97602) (GH-97608)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 28 Sep 2022 04:32:01 +0000 (21:32 -0700)
committerPablo Galindo <pablogsal@gmail.com>
Sat, 22 Oct 2022 19:05:57 +0000 (20:05 +0100)
Doc/howto/logging-cookbook.rst

index d1c3534a835166da3ae30f5f234822e376978a78..b49b00dc38616dffa9514e08c258e6c15e374222 100644 (file)
@@ -604,6 +604,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