]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779)
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 14 Jun 2022 05:41:16 +0000 (06:41 +0100)
committerGitHub <noreply@github.com>
Tue, 14 Jun 2022 05:41:16 +0000 (06:41 +0100)
Lib/test/test_logging.py

index 87b3efa4065726f3efcfaff80667c067d658dcc9..49545573682d0035eb8983f5977a11535ce0d4b8 100644 (file)
@@ -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'])