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

Small idea:

Could we add __enter__ and __exit__ to logging.handlers.QueueListener?

On enter → call start()
On exit → call stop()

I was using this and figured this would be a thing, but then it wasn’t.

If it sounds good, I’d be happy to PR, etc. :slight_smile:

1 Like

Filed Allow logging.handlers.QueueListener to be used as a context manager · Issue #132106 · python/cpython · GitHub