From 6e5b7cbca01df4abd673feb0482b8aeaa574bef5 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 13 Jun 2022 17:49:59 +0100 Subject: [PATCH] gh-93761: Fix test to avoid simple delay when synchronizing. --- Lib/test/test_logging.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 87b3efa4065726..49545573682d00 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'])