[Python-checkins] gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779)

vsajip webhook-mailer at python.org
Tue Jun 14 01:41:45 EDT 2022


https://github.com/python/cpython/commit/5bcf33de0b6729bbd4ced442f69c55ff99ea4be0
commit: 5bcf33de0b6729bbd4ced442f69c55ff99ea4be0
branch: main
author: Vinay Sajip <vinay_sajip at yahoo.co.uk>
committer: vsajip <vinay_sajip at yahoo.co.uk>
date: 2022-06-14T06:41:16+01:00
summary:

gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779)

files:
M Lib/test/test_logging.py

diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 87b3efa406572..49545573682d0 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3609,13 +3609,15 @@ def do_queuehandler_configuration(self, qspec, lspec):
             self.assertEqual(sorted(logging.getHandlerNames()), ['ah', 'h1'])
             self.assertIsNotNone(qh.listener)
             qh.listener.start()
-            # Need to let the listener thread get started
-            time.sleep(delay)
             logging.debug('foo')
             logging.info('bar')
             logging.warning('baz')
             # Need to let the listener thread finish its work
-            time.sleep(delay)
+            deadline = time.monotonic() + support.LONG_TIMEOUT
+            while not qh.listener.queue.empty():
+                time.sleep(delay)
+                if time.monotonic() > deadline:
+                    self.fail("queue not empty")
             with open(fn, encoding='utf-8') as f:
                 data = f.read().splitlines()
             self.assertEqual(data, ['foo', 'bar', 'baz'])



More information about the Python-checkins mailing list