[Python-checkins] bpo-31234: test_multiprocessing: wait 30 seconds (#3599)

Victor Stinner webhook-mailer at python.org
Fri Sep 15 09:55:34 EDT 2017


https://github.com/python/cpython/commit/11f0807a407551d498bb6bd8cc932636f75f1cd7
commit: 11f0807a407551d498bb6bd8cc932636f75f1cd7
branch: master
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017年09月15日T06:55:31-07:00
summary:
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.
files:
M Lib/test/_test_multiprocessing.py
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index bddcdadfeee..fda20f1f408 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -63,6 +63,9 @@
 #
 #
 
+# Timeout to wait until a process completes
+TIMEOUT = 30.0 # seconds
+
 def latin(s):
 return s.encode('latin')
 
@@ -73,10 +76,10 @@ def close_queue(queue):
 queue.join_thread()
 
 
-def join_process(process, timeout):
+def join_process(process):
 # Since multiprocessing.Process has the same API than threading.Thread
 # (join() and is_alive(), the support function can be reused
- support.join_thread(process, timeout)
+ support.join_thread(process, timeout=TIMEOUT)
 
 
 #
@@ -484,7 +487,7 @@ def test_many_processes(self):
 for p in procs:
 p.start()
 for p in procs:
- join_process(p, timeout=10)
+ join_process(p)
 for p in procs:
 self.assertEqual(p.exitcode, 0)
 
@@ -496,7 +499,7 @@ def test_many_processes(self):
 for p in procs:
 p.terminate()
 for p in procs:
- join_process(p, timeout=10)
+ join_process(p)
 if os.name != 'nt':
 for p in procs:
 self.assertEqual(p.exitcode, -signal.SIGTERM)
@@ -659,7 +662,7 @@ def test_sys_exit(self):
 p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
 p.daemon = True
 p.start()
- join_process(p, timeout=5)
+ join_process(p)
 self.assertEqual(p.exitcode, 1)
 
 with open(testfn, 'r') as f:
@@ -672,7 +675,7 @@ def test_sys_exit(self):
 p = self.Process(target=sys.exit, args=(reason,))
 p.daemon = True
 p.start()
- join_process(p, timeout=5)
+ join_process(p)
 self.assertEqual(p.exitcode, reason)
 
 #
@@ -1261,7 +1264,7 @@ def test_waitfor(self):
 state.value += 1
 cond.notify()
 
- join_process(p, timeout=5)
+ join_process(p)
 self.assertEqual(p.exitcode, 0)
 
 @classmethod
@@ -1288,7 +1291,7 @@ def test_waitfor_timeout(self):
 args=(cond, state, success, sem))
 p.daemon = True
 p.start()
- self.assertTrue(sem.acquire(timeout=10))
+ self.assertTrue(sem.acquire(timeout=TIMEOUT))
 
 # Only increment 3 times, so state == 4 is never reached.
 for i in range(3):
@@ -1297,7 +1300,7 @@ def test_waitfor_timeout(self):
 state.value += 1
 cond.notify()
 
- join_process(p, timeout=5)
+ join_process(p)
 self.assertTrue(success.value)
 
 @classmethod
@@ -3079,7 +3082,7 @@ class _TestPicklingConnections(BaseTestCase):
 @classmethod
 def tearDownClass(cls):
 from multiprocessing import resource_sharer
- resource_sharer.stop(timeout=5)
+ resource_sharer.stop(timeout=TIMEOUT)
 
 @classmethod
 def _listener(cls, conn, families):
@@ -4011,7 +4014,7 @@ def test_timeout(self):
 self.assertEqual(conn.recv(), 456)
 conn.close()
 l.close()
- join_process(p, timeout=10)
+ join_process(p)
 finally:
 socket.setdefaulttimeout(old_timeout)
 
@@ -4047,7 +4050,7 @@ def child(cls, n, conn):
 p = multiprocessing.Process(target=cls.child, args=(n-1, conn))
 p.start()
 conn.close()
- join_process(p, timeout=5)
+ join_process(p)
 else:
 conn.send(len(util._afterfork_registry))
 conn.close()
@@ -4060,7 +4063,7 @@ def test_lock(self):
 p.start()
 w.close()
 new_size = r.recv()
- join_process(p, timeout=5)
+ join_process(p)
 self.assertLessEqual(new_size, old_size)
 
 #
@@ -4115,7 +4118,7 @@ def test_closefd(self):
 p.start()
 writer.close()
 e = reader.recv()
- join_process(p, timeout=5)
+ join_process(p)
 finally:
 self.close(fd)
 writer.close()


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /