mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-132106: Ensure that running logging.handlers.QueueListener
cannot be started again (GH-132444)
Prevents a thread leak Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
64b066ad29
commit
5863cd70b8
5 changed files with 24 additions and 0 deletions
|
@ -4356,6 +4356,17 @@ class QueueHandlerTest(BaseTest):
|
|||
listener.stop()
|
||||
self.assertIsNone(listener._thread)
|
||||
|
||||
def test_queue_listener_multi_start(self):
|
||||
handler = TestHandler(support.Matcher())
|
||||
with logging.handlers.QueueListener(self.queue, handler) as listener:
|
||||
self.assertRaises(RuntimeError, listener.start)
|
||||
|
||||
with listener:
|
||||
self.assertRaises(RuntimeError, listener.start)
|
||||
|
||||
listener.start()
|
||||
listener.stop()
|
||||
|
||||
def test_queue_listener_with_StreamHandler(self):
|
||||
# Test that traceback and stack-info only appends once (bpo-34334, bpo-46755).
|
||||
listener = logging.handlers.QueueListener(self.queue, self.root_hdlr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue