Title: Logging QueueListener should support context manager
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: sbrugman, vinay.sajip
Priority: normal Keywords: patch

Created on 2020-02-09 03:31 by sbrugman, last changed 2020-02-20 18:42 by vinay.sajip. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18417 closed sbrugman, 2020-02-09 03:33
PR 18563 closed sbrugman, 2020-02-19 16:32
Messages (3)
msg361641 - (view) Author: Simon (sbrugman) * Date: 2020-02-09 03:31
The QueueListener could be extended to support the context manager.
msg362283 - (view) Author: Simon (sbrugman) * Date: 2020-02-19 16:08
The QueueListener in the logging library starts a background thread to monitor the log event queue. The context manager support is ideal in this case, making the code simpler, more consistent with other classes (e.g. multiprocessing.Pool) and prompts stopping the thread.

Without support for the context manager we need the following code:

queue_listener = QueueListener(queue, handler)
# queue messages

adding context manager support would result in the following equivalent code:

with QueueListener(queue, handler) as queue_listener:
    # queue messages
msg362290 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-02-19 19:57
See my comments on the PR. I think this issue and the PR should be closed.
Date User Action Args
2020-02-20 18:42:39vinay.sajipsetstatus: open -> closed
resolution: not a bug
stage: patch review -> resolved
2020-02-19 19:57:49vinay.sajipsetmessages: + msg362290
2020-02-19 16:36:35xtreaksetnosy: + vinay.sajip
2020-02-19 16:32:41sbrugmansetpull_requests: + pull_request17944
2020-02-19 16:08:37sbrugmansetmessages: + msg362283
2020-02-09 03:33:15sbrugmansetkeywords: + patch
stage: patch review
pull_requests: + pull_request17792
2020-02-09 03:31:28sbrugmancreate