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

@ -28,16 +28,15 @@ class InterProcessSignalTests(unittest.TestCase):
# (if set)
child.wait()
timeout = support.SHORT_TIMEOUT
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
start_time = time.monotonic()
for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
if self.got_signals[signame]:
return
signal.pause()
self.fail('signal %s not received after %s seconds'
% (signame, timeout))
else:
dt = time.monotonic() - start_time
self.fail('signal %s not received after %.1f seconds'
% (signame, dt))
def subprocess_send_signal(self, pid, signame):
code = 'import os, signal; os.kill(%s, signal.%s)' % (pid, signame)