Simon <[email protected]> added the comment:
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_listener.start()
# queue messages
queue_listener.stop()
```
adding context manager support would result in the following equivalent code:
```
with QueueListener(queue, handler) as queue_listener:
# queue messages
```
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39589>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com