Skip to content

Commit 6e5b7cb

Browse files
committed
pythongh-93761: Fix test to avoid simple delay when synchronizing.
1 parent 3ceb4b8 commit 6e5b7cb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_logging.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3609,13 +3609,15 @@ def do_queuehandler_configuration(self, qspec, lspec):
36093609
self.assertEqual(sorted(logging.getHandlerNames()), ['ah', 'h1'])
36103610
self.assertIsNotNone(qh.listener)
36113611
qh.listener.start()
3612-
# Need to let the listener thread get started
3613-
time.sleep(delay)
36143612
logging.debug('foo')
36153613
logging.info('bar')
36163614
logging.warning('baz')
36173615
# Need to let the listener thread finish its work
3618-
time.sleep(delay)
3616+
deadline = time.monotonic() + support.LONG_TIMEOUT
3617+
while not qh.listener.queue.empty():
3618+
time.sleep(delay)
3619+
if time.monotonic() > deadline:
3620+
self.fail("queue not empty")
36193621
with open(fn, encoding='utf-8') as f:
36203622
data = f.read().splitlines()
36213623
self.assertEqual(data, ['foo', 'bar', 'baz'])

0 commit comments

Comments
 (0)