summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorBar Harel <bzvi7919@gmail.com>2019-06-01 09:19:09 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-01 09:19:09 (GMT)
commit6b282e18877ec84e927b381b4ce187eaf4ba3dd7 (patch)
tree67b8d2c67bc175ee2fcbf2d5164e4dcba6291c50 /Lib/test/test_logging.py
parent70c5f2ae6e6a07d44a8d3f3202ea01bf697e05db (diff)
downloadcpython-6b282e18877ec84e927b381b4ce187eaf4ba3dd7.zip
cpython-6b282e18877ec84e927b381b4ce187eaf4ba3dd7.tar.gz
cpython-6b282e18877ec84e927b381b4ce187eaf4ba3dd7.tar.bz2
bpo-36813: Fix QueueListener to call task_done() upon termination. (GH-13113)
Fixed QueueListener in order to avoid random deadlocks. Unable to add regression tests atm due to time constraints, will add it in a bit. Regarding implementation, although it's nested, it does not cause performance issues whatsoever, and does not call task_done() in case of an exception (which is the right thing to do IMHO). https://bugs.python.org/issue36813
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index b884753..50148dc 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3633,6 +3633,16 @@ if hasattr(logging.handlers, 'QueueListener'):
[m.msg if isinstance(m, logging.LogRecord)
else m for m in items]))
+ def test_calls_task_done_after_stop(self):
+ # Issue 36813: Make sure queue.join does not deadlock.
+ log_queue = queue.Queue()
+ listener = logging.handlers.QueueListener(log_queue)
+ listener.start()
+ listener.stop()
+ with self.assertRaises(ValueError):
+ # Make sure all tasks are done and .join won't block.
+ log_queue.task_done()
+
ZERO = datetime.timedelta(0)