diff options
author | Charles Machalow <csm10495@gmail.com> | 2025-04-13 00:53:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-13 08:53:13 +0100 |
commit | 5863cd70b8782313b52bb8c71a4127d7ea4c50e9 (patch) | |
tree | f8bba8012267489bc615b3cecdb487d32ce55b3c /Lib/test/test_logging.py | |
parent | 64b066ad298506f715647c9a2524c9fbbc764cc2 (diff) | |
download | cpython-5863cd70b8782313b52bb8c71a4127d7ea4c50e9.tar.gz cpython-5863cd70b8782313b52bb8c71a4127d7ea4c50e9.zip |
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>
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 11f6b64abe2..9305844829a 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -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) |