bpo-31234: test_multiprocessing: wait 30 seconds (#3599) · python/cpython@11f0807
@@ -63,6 +63,9 @@
6363#
6464#
656566+# Timeout to wait until a process completes
67+TIMEOUT = 30.0 # seconds
68+6669def latin(s):
6770return s.encode('latin')
6871@@ -73,10 +76,10 @@ def close_queue(queue):
7376queue.join_thread()
7477757876-def join_process(process, timeout):
79+def join_process(process):
7780# Since multiprocessing.Process has the same API than threading.Thread
7881# (join() and is_alive(), the support function can be reused
79-support.join_thread(process, timeout)
82+support.join_thread(process, timeout=TIMEOUT)
808381848285#
@@ -484,7 +487,7 @@ def test_many_processes(self):
484487for p in procs:
485488p.start()
486489for p in procs:
487-join_process(p, timeout=10)
490+join_process(p)
488491for p in procs:
489492self.assertEqual(p.exitcode, 0)
490493@@ -496,7 +499,7 @@ def test_many_processes(self):
496499for p in procs:
497500p.terminate()
498501for p in procs:
499-join_process(p, timeout=10)
502+join_process(p)
500503if os.name != 'nt':
501504for p in procs:
502505self.assertEqual(p.exitcode, -signal.SIGTERM)
@@ -659,7 +662,7 @@ def test_sys_exit(self):
659662p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
660663p.daemon = True
661664p.start()
662-join_process(p, timeout=5)
665+join_process(p)
663666self.assertEqual(p.exitcode, 1)
664667665668with open(testfn, 'r') as f:
@@ -672,7 +675,7 @@ def test_sys_exit(self):
672675p = self.Process(target=sys.exit, args=(reason,))
673676p.daemon = True
674677p.start()
675-join_process(p, timeout=5)
678+join_process(p)
676679self.assertEqual(p.exitcode, reason)
677680678681#
@@ -1261,7 +1264,7 @@ def test_waitfor(self):
12611264state.value += 1
12621265cond.notify()
126312661264-join_process(p, timeout=5)
1267+join_process(p)
12651268self.assertEqual(p.exitcode, 0)
1266126912671270@classmethod
@@ -1288,7 +1291,7 @@ def test_waitfor_timeout(self):
12881291args=(cond, state, success, sem))
12891292p.daemon = True
12901293p.start()
1291-self.assertTrue(sem.acquire(timeout=10))
1294+self.assertTrue(sem.acquire(timeout=TIMEOUT))
1292129512931296# Only increment 3 times, so state == 4 is never reached.
12941297for i in range(3):
@@ -1297,7 +1300,7 @@ def test_waitfor_timeout(self):
12971300state.value += 1
12981301cond.notify()
129913021300-join_process(p, timeout=5)
1303+join_process(p)
13011304self.assertTrue(success.value)
1302130513031306@classmethod
@@ -3079,7 +3082,7 @@ class _TestPicklingConnections(BaseTestCase):
30793082@classmethod
30803083def tearDownClass(cls):
30813084from multiprocessing import resource_sharer
3082-resource_sharer.stop(timeout=5)
3085+resource_sharer.stop(timeout=TIMEOUT)
3083308630843087@classmethod
30853088def _listener(cls, conn, families):
@@ -4011,7 +4014,7 @@ def test_timeout(self):
40114014self.assertEqual(conn.recv(), 456)
40124015conn.close()
40134016l.close()
4014-join_process(p, timeout=10)
4017+join_process(p)
40154018finally:
40164019socket.setdefaulttimeout(old_timeout)
40174020@@ -4047,7 +4050,7 @@ def child(cls, n, conn):
40474050p = multiprocessing.Process(target=cls.child, args=(n-1, conn))
40484051p.start()
40494052conn.close()
4050-join_process(p, timeout=5)
4053+join_process(p)
40514054else:
40524055conn.send(len(util._afterfork_registry))
40534056conn.close()
@@ -4060,7 +4063,7 @@ def test_lock(self):
40604063p.start()
40614064w.close()
40624065new_size = r.recv()
4063-join_process(p, timeout=5)
4066+join_process(p)
40644067self.assertLessEqual(new_size, old_size)
4065406840664069#
@@ -4115,7 +4118,7 @@ def test_closefd(self):
41154118p.start()
41164119writer.close()
41174120e = reader.recv()
4118-join_process(p, timeout=5)
4121+join_process(p)
41194122finally:
41204123self.close(fd)
41214124writer.close()