summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-06-15 16:28:00 (GMT)
committerGitHub <noreply@github.com>2022-06-15 16:28:00 (GMT)
commit41fccd23e9b4397d6cc294b42e1a198cd8f8b268 (patch)
tree1d6bf960cbbaf6c97e40d9e95534fcb12f5cab0e /Lib
parent99be1cbeb3b58f0daa9108abc4075412d6212169 (diff)
downloadcpython-41fccd23e9b4397d6cc294b42e1a198cd8f8b268.zip
cpython-41fccd23e9b4397d6cc294b42e1a198cd8f8b268.tar.gz
cpython-41fccd23e9b4397d6cc294b42e1a198cd8f8b268.tar.bz2
test_asyncio: run_until() implements exponential sleep (#93866)
run_until() of test.test_asyncio.utils now uses an exponential sleep delay (max: 1 second), rather than a fixed delay of 1 ms. Similar design than support.sleeping_retry() wait strategy that applies exponential backoff.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_asyncio/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py
index 07ef33d..507daa1 100644
--- a/Lib/test/test_asyncio/utils.py
+++ b/Lib/test/test_asyncio/utils.py
@@ -109,10 +109,12 @@ def run_briefly(loop):
def run_until(loop, pred, timeout=support.SHORT_TIMEOUT):
+ delay = 0.001
for _ in support.busy_retry(timeout, error=False):
if pred():
break
- loop.run_until_complete(tasks.sleep(0.001))
+ loop.run_until_complete(tasks.sleep(delay))
+ delay = max(delay * 2, 1.0)
else:
raise futures.TimeoutError()