mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +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
|
@ -76,8 +76,7 @@ def capture_server(evt, buf, serv):
|
|||
pass
|
||||
else:
|
||||
n = 200
|
||||
start = time.monotonic()
|
||||
while n > 0 and time.monotonic() - start < 3.0:
|
||||
for _ in support.busy_retry(3.0, error=False):
|
||||
r, w, e = select.select([conn], [], [], 0.1)
|
||||
if r:
|
||||
n -= 1
|
||||
|
@ -86,6 +85,8 @@ def capture_server(evt, buf, serv):
|
|||
buf.write(data.replace(b'\n', b''))
|
||||
if b'\n' in data:
|
||||
break
|
||||
if n <= 0:
|
||||
break
|
||||
time.sleep(0.01)
|
||||
|
||||
conn.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue