Skip to content

Allow logging.handlers.QueueListener to be used as a context manager #132106

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

Closed
csm10495 opened this issue Apr 5, 2025 · 0 comments
Closed

Allow logging.handlers.QueueListener to be used as a context manager #132106

csm10495 opened this issue Apr 5, 2025 · 0 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@csm10495
Copy link
Contributor

csm10495 commented Apr 5, 2025

Feature or enhancement

Proposal:

This is a simple change that would allow:

         with QueueListener(queue, handler1) as listener:
             # the listener has started
             ...
         # the listener has stopped

It's a welcomed alternative to needing to call start/stop manually.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/allow-logging-handlers-queuelistener-to-be-used-as-a-context-manager/87124

Linked PRs

@csm10495 csm10495 added the type-feature A feature request or enhancement label Apr 5, 2025
@picnixz picnixz added the stdlib Python modules in the Lib dir label Apr 5, 2025
picnixz pushed a commit that referenced this issue Apr 12, 2025
csm10495 added a commit to csm10495/cpython that referenced this issue Apr 12, 2025
csm10495 added a commit to csm10495/cpython that referenced this issue Apr 12, 2025
vsajip pushed a commit that referenced this issue Apr 13, 2025
…t be started again (GH-132444)

Prevents a thread leak
Co-authored-by: Bénédikt Tran <[email protected]>
vsajip pushed a commit to vsajip/cpython that referenced this issue Apr 13, 2025
…stener` cannot be started again (pythonGH-132444)

Prevents a thread leak
Co-authored-by: Bénédikt Tran <[email protected]>
(cherry picked from commit 5863cd7)

Co-authored-by: Charles Machalow <[email protected]>
@vsajip vsajip closed this as completed Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
Development

No branches or pull requests

3 participants