mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
bddbd80cff
commit
0ba80273f2
7 changed files with 51 additions and 58 deletions
|
@ -109,13 +109,12 @@ def run_briefly(loop):
|
|||
|
||||
|
||||
def run_until(loop, pred, timeout=support.SHORT_TIMEOUT):
|
||||
deadline = time.monotonic() + timeout
|
||||
while not pred():
|
||||
if timeout is not None:
|
||||
timeout = deadline - time.monotonic()
|
||||
if timeout <= 0:
|
||||
raise futures.TimeoutError()
|
||||
for _ in support.busy_retry(timeout, error=False):
|
||||
if pred():
|
||||
break
|
||||
loop.run_until_complete(tasks.sleep(0.001))
|
||||
else:
|
||||
raise futures.TimeoutError()
|
||||
|
||||
|
||||
def run_once(loop):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue