Skip to content

Commit 41fccd2

Browse files
authored
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.
1 parent 99be1cb commit 41fccd2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_asyncio/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ async def once():
109109

110110

111111
def run_until(loop, pred, timeout=support.SHORT_TIMEOUT):
112+
delay = 0.001
112113
for _ in support.busy_retry(timeout, error=False):
113114
if pred():
114115
break
115-
loop.run_until_complete(tasks.sleep(0.001))
116+
loop.run_until_complete(tasks.sleep(delay))
117+
delay = max(delay * 2, 1.0)
116118
else:
117119
raise futures.TimeoutError()
118120

0 commit comments

Comments
 (0)