Skip to content

Commit 3853ba8

Browse files
committed
Call busy_retry() and sleeping_retry() with error=True
Tests no longer call busy_retry() and sleeping_retry() with error=False: raise an exception if the loop times out.
1 parent 50e0866 commit 3853ba8

6 files changed

+9
-18
lines changed

Lib/test/fork_wait.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_wait(self):
5454
self.threads.append(thread)
5555

5656
# busy-loop to wait for threads
57-
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
57+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
5858
if len(self.alive) >= NUM_THREADS:
5959
break
6060

Lib/test/test_asyncore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def capture_server(evt, buf, serv):
7676
pass
7777
else:
7878
n = 200
79-
for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
79+
for _ in support.busy_retry(support.SHORT_TIMEOUT):
8080
r, w, e = select.select([conn], [], [], 0.1)
8181
if r:
8282
n -= 1

Lib/test/test_logging.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -3613,11 +3613,10 @@ def do_queuehandler_configuration(self, qspec, lspec):
36133613
logging.warning('baz')
36143614

36153615
# Need to let the listener thread finish its work
3616-
while support.sleeping_retry(support.LONG_TIMEOUT, error=False):
3616+
while support.sleeping_retry(support.LONG_TIMEOUT,
3617+
"queue not empty"):
36173618
if qh.listener.queue.empty():
36183619
break
3619-
else:
3620-
self.fail("queue not empty")
36213620

36223621
with open(fn, encoding='utf-8') as f:
36233622
data = f.read().splitlines()

Lib/test/test_signal.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -812,16 +812,12 @@ def test_itimer_virtual(self):
812812
signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
813813
signal.setitimer(self.itimer, 0.3, 0.2)
814814

815-
for _ in support.busy_retry(support.LONG_TIMEOUT, error=False):
815+
for _ in support.busy_retry(support.LONG_TIMEOUT):
816816
# use up some virtual time by doing real work
817817
_ = pow(12345, 67890, 10000019)
818818
if signal.getitimer(self.itimer) == (0.0, 0.0):
819819
# sig_vtalrm handler stopped this itimer
820820
break
821-
else:
822-
# bpo-8424
823-
self.skipTest("timeout: likely cause: machine too slow or load too "
824-
"high")
825821

826822
# virtual itimer should be (0.0, 0.0) now
827823
self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
@@ -833,16 +829,12 @@ def test_itimer_prof(self):
833829
signal.signal(signal.SIGPROF, self.sig_prof)
834830
signal.setitimer(self.itimer, 0.2, 0.2)
835831

836-
for _ in support.busy_retry(support.LONG_TIMEOUT, error=False):
832+
for _ in support.busy_retry(support.LONG_TIMEOUT):
837833
# do some work
838834
_ = pow(12345, 67890, 10000019)
839835
if signal.getitimer(self.itimer) == (0.0, 0.0):
840836
# sig_prof handler stopped this itimer
841837
break
842-
else:
843-
# bpo-8424
844-
self.skipTest("timeout: likely cause: machine too slow or load too "
845-
"high")
846838

847839
# profiling itimer should be (0.0, 0.0) now
848840
self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
@@ -1317,7 +1309,7 @@ def handler(signum, frame):
13171309

13181310
expected_sigs += 2
13191311
# Wait for handlers to run to avoid signal coalescing
1320-
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
1312+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
13211313
if len(sigs) >= expected_sigs:
13221314
break
13231315

Lib/test/test_wait3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def wait_impl(self, cpid, *, exitcode):
1919
# This many iterations can be required, since some previously run
2020
# tests (e.g. test_ctypes) could have spawned a lot of children
2121
# very quickly.
22-
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
22+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
2323
# wait3() shouldn't hang, but some of the buildbots seem to hang
2424
# in the forking tests. This is an attempt to fix the problem.
2525
spid, status, rusage = os.wait3(os.WNOHANG)

Lib/test/test_wait4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def wait_impl(self, cpid, *, exitcode):
2121
# Issue #11185: wait4 is broken on AIX and will always return 0
2222
# with WNOHANG.
2323
option = 0
24-
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
24+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
2525
# wait4() shouldn't hang, but some of the buildbots seem to hang
2626
# in the forking tests. This is an attempt to fix the problem.
2727
spid, status, rusage = os.wait4(cpid, option)

0 commit comments

Comments
 (0)