summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-06-15 12:09:56 (GMT)
committerGitHub <noreply@github.com>2022-06-15 12:09:56 (GMT)
commit0ba80273f2dba5b70de870a333e65ad025cca640 (patch)
tree7f21af5a00c17463625072031650af5bd50895ea /Lib/test/test_logging.py
parentbddbd80cff950b16712ae9e72eeba2a0f26c65e0 (diff)
downloadcpython-0ba80273f2dba5b70de870a333e65ad025cca640.zip
cpython-0ba80273f2dba5b70de870a333e65ad025cca640.tar.gz
cpython-0ba80273f2dba5b70de870a333e65ad025cca640.tar.bz2
Use support.sleeping_retry() and support.busy_retry() (#93848)
* Replace time.sleep(0.010) with sleeping_retry() to use an exponential sleep. * support.wait_process(): reuse sleeping_retry(). * _test_eintr: remove unused variables.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 4954557..d43742e 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3602,7 +3602,6 @@ class ConfigDictTest(BaseTest):
if lspec is not None:
cd['handlers']['ah']['listener'] = lspec
qh = None
- delay = 0.01
try:
self.apply_config(cd)
qh = logging.getHandlerByName('ah')
@@ -3612,12 +3611,14 @@ class ConfigDictTest(BaseTest):
logging.debug('foo')
logging.info('bar')
logging.warning('baz')
+
# Need to let the listener thread finish its work
- deadline = time.monotonic() + support.LONG_TIMEOUT
- while not qh.listener.queue.empty():
- time.sleep(delay)
- if time.monotonic() > deadline:
- self.fail("queue not empty")
+ while support.sleeping_retry(support.LONG_TIMEOUT, error=False):
+ if qh.listener.queue.empty():
+ break
+ else:
+ self.fail("queue not empty")
+
with open(fn, encoding='utf-8') as f:
data = f.read().splitlines()
self.assertEqual(data, ['foo', 'bar', 'baz'])