]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Call busy_retry() and sleeping_retry() with error=True (#93871)
authorVictor Stinner <vstinner@python.org>
Thu, 16 Jun 2022 11:44:58 +0000 (13:44 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Jun 2022 11:44:58 +0000 (13:44 +0200)
Tests no longer call busy_retry() and sleeping_retry() with
error=False: raise an exception if the loop times out.

Lib/test/fork_wait.py
Lib/test/test_asyncore.py
Lib/test/test_logging.py
Lib/test/test_signal.py
Lib/test/test_wait3.py
Lib/test/test_wait4.py

index c565f593559483aab85b57fc625e92ed7c31e44c..ebd07e612e5810f0f5b33222e417177987a2a9cf 100644 (file)
@@ -54,7 +54,7 @@ class ForkWait(unittest.TestCase):
             self.threads.append(thread)
 
         # busy-loop to wait for threads
-        for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
+        for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
             if len(self.alive) >= NUM_THREADS:
                 break
 
index 7d3e2011189a5fbad9af83f4b91c3b7a552f0e20..5a037fb9c5d5954255b78c6088bbf13e01bb38d0 100644 (file)
@@ -76,7 +76,7 @@ def capture_server(evt, buf, serv):
         pass
     else:
         n = 200
-        for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
+        for _ in support.busy_retry(support.SHORT_TIMEOUT):
             r, w, e = select.select([conn], [], [], 0.1)
             if r:
                 n -= 1
index d43742ef603f9e6b02421f9489a43d2c554c33e4..5200281769f764e943bf1a0ebf8cc8041c3f77ba 100644 (file)
@@ -3613,11 +3613,10 @@ class ConfigDictTest(BaseTest):
             logging.warning('baz')
 
             # Need to let the listener thread finish its work
-            while support.sleeping_retry(support.LONG_TIMEOUT, error=False):
+            while support.sleeping_retry(support.LONG_TIMEOUT,
+                                         "queue not empty"):
                 if qh.listener.queue.empty():
                     break
-            else:
-                self.fail("queue not empty")
 
             with open(fn, encoding='utf-8') as f:
                 data = f.read().splitlines()
index 2e115f45be4727192e5520666a12b754bf4cb9ad..2562a57ea421ffd4bd36e292e949caf0072b1541 100644 (file)
@@ -812,16 +812,12 @@ class ItimerTest(unittest.TestCase):
         signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
         signal.setitimer(self.itimer, 0.3, 0.2)
 
-        for _ in support.busy_retry(support.LONG_TIMEOUT, error=False):
+        for _ in support.busy_retry(support.LONG_TIMEOUT):
             # use up some virtual time by doing real work
             _ = pow(12345, 67890, 10000019)
             if signal.getitimer(self.itimer) == (0.0, 0.0):
                 # sig_vtalrm handler stopped this itimer
                 break
-        else:
-            # bpo-8424
-            self.skipTest("timeout: likely cause: machine too slow or load too "
-                          "high")
 
         # virtual itimer should be (0.0, 0.0) now
         self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
@@ -833,16 +829,12 @@ class ItimerTest(unittest.TestCase):
         signal.signal(signal.SIGPROF, self.sig_prof)
         signal.setitimer(self.itimer, 0.2, 0.2)
 
-        for _ in support.busy_retry(support.LONG_TIMEOUT, error=False):
+        for _ in support.busy_retry(support.LONG_TIMEOUT):
             # do some work
             _ = pow(12345, 67890, 10000019)
             if signal.getitimer(self.itimer) == (0.0, 0.0):
                 # sig_prof handler stopped this itimer
                 break
-        else:
-            # bpo-8424
-            self.skipTest("timeout: likely cause: machine too slow or load too "
-                          "high")
 
         # profiling itimer should be (0.0, 0.0) now
         self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
@@ -1317,7 +1309,7 @@ class StressTest(unittest.TestCase):
 
             expected_sigs += 2
             # Wait for handlers to run to avoid signal coalescing
-            for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
+            for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
                 if len(sigs) >= expected_sigs:
                     break
 
index 15d66ae825abf53f786ac3656db324b4d532590a..eae885a61300bedd5d5befb0948d1125ef836afb 100644 (file)
@@ -19,7 +19,7 @@ class Wait3Test(ForkWait):
         # This many iterations can be required, since some previously run
         # tests (e.g. test_ctypes) could have spawned a lot of children
         # very quickly.
-        for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
+        for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
             # wait3() shouldn't hang, but some of the buildbots seem to hang
             # in the forking tests.  This is an attempt to fix the problem.
             spid, status, rusage = os.wait3(os.WNOHANG)
index f66c0db1c20e6e628cd380ed377a4647a7c14d47..67afab1d6f2e3c53c3a026f1bdf25219e5575210 100644 (file)
@@ -21,7 +21,7 @@ class Wait4Test(ForkWait):
             # Issue #11185: wait4 is broken on AIX and will always return 0
             # with WNOHANG.
             option = 0
-        for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
+        for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
             # wait4() shouldn't hang, but some of the buildbots seem to hang
             # in the forking tests.  This is an attempt to fix the problem.
             spid, status, rusage = os.wait4(cpid, option)