Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test_asyncio: run_until() implements exponential sleep
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.
  • Loading branch information
vstinner committed Jun 15, 2022
commit c5aae91934f2fff20abc274225a7e565ac15d669
4 changes: 3 additions & 1 deletion Lib/test/test_asyncio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ async def once():


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()

Expand Down