From: Vinay Sajip Date: Tue, 14 Jun 2022 05:41:16 +0000 (+0100) Subject: gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779) X-Git-Tag: v3.12.0a1~1275 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bcf33de0b6729bbd4ced442f69c55ff99ea4be0;p=thirdparty%2FPython%2Fcpython.git gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779) --- diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 87b3efa40657..49545573682d 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3609,13 +3609,15 @@ class ConfigDictTest(BaseTest): 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'])