63
63
#
64
64
#
65
65
66
+ # Timeout to wait until a process completes
67
+ TIMEOUT = 30.0 # seconds
68
+
66
69
def latin (s ):
67
70
return s .encode ('latin' )
68
71
@@ -73,10 +76,10 @@ def close_queue(queue):
73
76
queue .join_thread ()
74
77
75
78
76
- def join_process (process , timeout ):
79
+ def join_process (process ):
77
80
# Since multiprocessing.Process has the same API than threading.Thread
78
81
# (join() and is_alive(), the support function can be reused
79
- support .join_thread (process , timeout )
82
+ support .join_thread (process , timeout = TIMEOUT )
80
83
81
84
82
85
#
@@ -484,7 +487,7 @@ def test_many_processes(self):
484
487
for p in procs :
485
488
p .start ()
486
489
for p in procs :
487
- join_process (p , timeout = 10 )
490
+ join_process (p )
488
491
for p in procs :
489
492
self .assertEqual (p .exitcode , 0 )
490
493
@@ -496,7 +499,7 @@ def test_many_processes(self):
496
499
for p in procs :
497
500
p .terminate ()
498
501
for p in procs :
499
- join_process (p , timeout = 10 )
502
+ join_process (p )
500
503
if os .name != 'nt' :
501
504
for p in procs :
502
505
self .assertEqual (p .exitcode , - signal .SIGTERM )
@@ -659,7 +662,7 @@ def test_sys_exit(self):
659
662
p = self .Process (target = self ._test_sys_exit , args = (reason , testfn ))
660
663
p .daemon = True
661
664
p .start ()
662
- join_process (p , timeout = 5 )
665
+ join_process (p )
663
666
self .assertEqual (p .exitcode , 1 )
664
667
665
668
with open (testfn , 'r' ) as f :
@@ -672,7 +675,7 @@ def test_sys_exit(self):
672
675
p = self .Process (target = sys .exit , args = (reason ,))
673
676
p .daemon = True
674
677
p .start ()
675
- join_process (p , timeout = 5 )
678
+ join_process (p )
676
679
self .assertEqual (p .exitcode , reason )
677
680
678
681
#
@@ -1261,7 +1264,7 @@ def test_waitfor(self):
1261
1264
state .value += 1
1262
1265
cond .notify ()
1263
1266
1264
- join_process (p , timeout = 5 )
1267
+ join_process (p )
1265
1268
self .assertEqual (p .exitcode , 0 )
1266
1269
1267
1270
@classmethod
@@ -1288,7 +1291,7 @@ def test_waitfor_timeout(self):
1288
1291
args = (cond , state , success , sem ))
1289
1292
p .daemon = True
1290
1293
p .start ()
1291
- self .assertTrue (sem .acquire (timeout = 10 ))
1294
+ self .assertTrue (sem .acquire (timeout = TIMEOUT ))
1292
1295
1293
1296
# Only increment 3 times, so state == 4 is never reached.
1294
1297
for i in range (3 ):
@@ -1297,7 +1300,7 @@ def test_waitfor_timeout(self):
1297
1300
state .value += 1
1298
1301
cond .notify ()
1299
1302
1300
- join_process (p , timeout = 5 )
1303
+ join_process (p )
1301
1304
self .assertTrue (success .value )
1302
1305
1303
1306
@classmethod
@@ -3079,7 +3082,7 @@ class _TestPicklingConnections(BaseTestCase):
3079
3082
@classmethod
3080
3083
def tearDownClass (cls ):
3081
3084
from multiprocessing import resource_sharer
3082
- resource_sharer .stop (timeout = 5 )
3085
+ resource_sharer .stop (timeout = TIMEOUT )
3083
3086
3084
3087
@classmethod
3085
3088
def _listener (cls , conn , families ):
@@ -4011,7 +4014,7 @@ def test_timeout(self):
4011
4014
self .assertEqual (conn .recv (), 456 )
4012
4015
conn .close ()
4013
4016
l .close ()
4014
- join_process (p , timeout = 10 )
4017
+ join_process (p )
4015
4018
finally :
4016
4019
socket .setdefaulttimeout (old_timeout )
4017
4020
@@ -4047,7 +4050,7 @@ def child(cls, n, conn):
4047
4050
p = multiprocessing .Process (target = cls .child , args = (n - 1 , conn ))
4048
4051
p .start ()
4049
4052
conn .close ()
4050
- join_process (p , timeout = 5 )
4053
+ join_process (p )
4051
4054
else :
4052
4055
conn .send (len (util ._afterfork_registry ))
4053
4056
conn .close ()
@@ -4060,7 +4063,7 @@ def test_lock(self):
4060
4063
p .start ()
4061
4064
w .close ()
4062
4065
new_size = r .recv ()
4063
- join_process (p , timeout = 5 )
4066
+ join_process (p )
4064
4067
self .assertLessEqual (new_size , old_size )
4065
4068
4066
4069
#
@@ -4115,7 +4118,7 @@ def test_closefd(self):
4115
4118
p .start ()
4116
4119
writer .close ()
4117
4120
e = reader .recv ()
4118
- join_process (p , timeout = 5 )
4121
+ join_process (p )
4119
4122
finally :
4120
4123
self .close (fd )
4121
4124
writer .close ()
0 commit comments