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:
Victor Stinner 2022-06-15 14:09:56 +02:00 committed by GitHub
parent bddbd80cff
commit 0ba80273f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 58 deletions

View file

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