gh-132106: Allow logging.handlers.QueueListener to be used as a context manager (#132107)

This commit is contained in:
Charles Machalow 2025-04-12 05:00:04 -07:00 committed by GitHub
parent ad3bbe8fbc
commit 517e96b9ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 54 additions and 6 deletions

View file

@ -626,6 +626,19 @@ which, when run, will produce:
of each message with the handler's level, and only passes a message to a
handler if it's appropriate to do so.
.. versionchanged:: next
The :class:`QueueListener` can be started (and stopped) via the
:keyword:`with` statement. For example:
.. code-block:: python
with QueueListener(que, handler) as listener:
# The queue listener automatically starts
# when the 'with' block is entered.
pass
# The queue listener automatically stops once
# the 'with' block is exited.
.. _network-logging:
Sending and receiving logging events across a network