Skip to content

Commit 11f0807

Browse files
authored
bpo-31234: test_multiprocessing: wait 30 seconds (#3599)
Give 30 seconds to join_process(), instead of 5 or 10 seconds, to wait until the process completes.
1 parent da3e5cf commit 11f0807

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
#
6464
#
6565

66+
# Timeout to wait until a process completes
67+
TIMEOUT = 30.0 # seconds
68+
6669
def latin(s):
6770
return s.encode('latin')
6871

@@ -73,10 +76,10 @@ def close_queue(queue):
7376
queue.join_thread()
7477

7578

76-
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)
8083

8184

8285
#
@@ -484,7 +487,7 @@ def test_many_processes(self):
484487
for p in procs:
485488
p.start()
486489
for p in procs:
487-
join_process(p, timeout=10)
490+
join_process(p)
488491
for p in procs:
489492
self.assertEqual(p.exitcode, 0)
490493

@@ -496,7 +499,7 @@ def test_many_processes(self):
496499
for p in procs:
497500
p.terminate()
498501
for p in procs:
499-
join_process(p, timeout=10)
502+
join_process(p)
500503
if os.name != 'nt':
501504
for p in procs:
502505
self.assertEqual(p.exitcode, -signal.SIGTERM)
@@ -659,7 +662,7 @@ def test_sys_exit(self):
659662
p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
660663
p.daemon = True
661664
p.start()
662-
join_process(p, timeout=5)
665+
join_process(p)
663666
self.assertEqual(p.exitcode, 1)
664667

665668
with open(testfn, 'r') as f:
@@ -672,7 +675,7 @@ def test_sys_exit(self):
672675
p = self.Process(target=sys.exit, args=(reason,))
673676
p.daemon = True
674677
p.start()
675-
join_process(p, timeout=5)
678+
join_process(p)
676679
self.assertEqual(p.exitcode, reason)
677680

678681
#
@@ -1261,7 +1264,7 @@ def test_waitfor(self):
12611264
state.value += 1
12621265
cond.notify()
12631266

1264-
join_process(p, timeout=5)
1267+
join_process(p)
12651268
self.assertEqual(p.exitcode, 0)
12661269

12671270
@classmethod
@@ -1288,7 +1291,7 @@ def test_waitfor_timeout(self):
12881291
args=(cond, state, success, sem))
12891292
p.daemon = True
12901293
p.start()
1291-
self.assertTrue(sem.acquire(timeout=10))
1294+
self.assertTrue(sem.acquire(timeout=TIMEOUT))
12921295

12931296
# Only increment 3 times, so state == 4 is never reached.
12941297
for i in range(3):
@@ -1297,7 +1300,7 @@ def test_waitfor_timeout(self):
12971300
state.value += 1
12981301
cond.notify()
12991302

1300-
join_process(p, timeout=5)
1303+
join_process(p)
13011304
self.assertTrue(success.value)
13021305

13031306
@classmethod
@@ -3079,7 +3082,7 @@ class _TestPicklingConnections(BaseTestCase):
30793082
@classmethod
30803083
def tearDownClass(cls):
30813084
from multiprocessing import resource_sharer
3082-
resource_sharer.stop(timeout=5)
3085+
resource_sharer.stop(timeout=TIMEOUT)
30833086

30843087
@classmethod
30853088
def _listener(cls, conn, families):
@@ -4011,7 +4014,7 @@ def test_timeout(self):
40114014
self.assertEqual(conn.recv(), 456)
40124015
conn.close()
40134016
l.close()
4014-
join_process(p, timeout=10)
4017+
join_process(p)
40154018
finally:
40164019
socket.setdefaulttimeout(old_timeout)
40174020

@@ -4047,7 +4050,7 @@ def child(cls, n, conn):
40474050
p = multiprocessing.Process(target=cls.child, args=(n-1, conn))
40484051
p.start()
40494052
conn.close()
4050-
join_process(p, timeout=5)
4053+
join_process(p)
40514054
else:
40524055
conn.send(len(util._afterfork_registry))
40534056
conn.close()
@@ -4060,7 +4063,7 @@ def test_lock(self):
40604063
p.start()
40614064
w.close()
40624065
new_size = r.recv()
4063-
join_process(p, timeout=5)
4066+
join_process(p)
40644067
self.assertLessEqual(new_size, old_size)
40654068

40664069
#
@@ -4115,7 +4118,7 @@ def test_closefd(self):
41154118
p.start()
41164119
writer.close()
41174120
e = reader.recv()
4118-
join_process(p, timeout=5)
4121+
join_process(p)
41194122
finally:
41204123
self.close(fd)
41214124
writer.close()

0 commit comments

Comments
 (0)