Commit 94f964f8 authored by Jesus Cea's avatar Jesus Cea

Close issue #12948: multiprocessing test failures can hang the buildbots

parent eb933de8
...@@ -267,6 +267,7 @@ class _TestProcess(BaseTestCase): ...@@ -267,6 +267,7 @@ class _TestProcess(BaseTestCase):
p = self.Process(target=time.sleep, args=(DELTA,)) p = self.Process(target=time.sleep, args=(DELTA,))
self.assertNotIn(p, self.active_children()) self.assertNotIn(p, self.active_children())
p.daemon = True
p.start() p.start()
self.assertIn(p, self.active_children()) self.assertIn(p, self.active_children())
...@@ -337,6 +338,7 @@ class _TestSubclassingProcess(BaseTestCase): ...@@ -337,6 +338,7 @@ class _TestSubclassingProcess(BaseTestCase):
def test_subclassing(self): def test_subclassing(self):
uppercaser = _UpperCaser() uppercaser = _UpperCaser()
uppercaser.daemon = True
uppercaser.start() uppercaser.start()
self.assertEqual(uppercaser.submit('hello'), 'HELLO') self.assertEqual(uppercaser.submit('hello'), 'HELLO')
self.assertEqual(uppercaser.submit('world'), 'WORLD') self.assertEqual(uppercaser.submit('world'), 'WORLD')
...@@ -515,6 +517,7 @@ class _TestQueue(BaseTestCase): ...@@ -515,6 +517,7 @@ class _TestQueue(BaseTestCase):
# fork process # fork process
p = self.Process(target=self._test_fork, args=(queue,)) p = self.Process(target=self._test_fork, args=(queue,))
p.daemon = True
p.start() p.start()
# check that all expected items are in the queue # check that all expected items are in the queue
...@@ -555,6 +558,7 @@ class _TestQueue(BaseTestCase): ...@@ -555,6 +558,7 @@ class _TestQueue(BaseTestCase):
for i in range(4)] for i in range(4)]
for p in workers: for p in workers:
p.daemon = True
p.start() p.start()
for i in range(10): for i in range(10):
...@@ -825,7 +829,9 @@ class _TestEvent(BaseTestCase): ...@@ -825,7 +829,9 @@ class _TestEvent(BaseTestCase):
#self.assertEqual(event.is_set(), False) #self.assertEqual(event.is_set(), False)
self.Process(target=self._test_event, args=(event,)).start() p = self.Process(target=self._test_event, args=(event,))
p.daemon = True
p.start()
self.assertEqual(wait(), True) self.assertEqual(wait(), True)
# #
...@@ -865,6 +871,7 @@ class _TestValue(BaseTestCase): ...@@ -865,6 +871,7 @@ class _TestValue(BaseTestCase):
self.assertEqual(sv.value, cv[1]) self.assertEqual(sv.value, cv[1])
proc = self.Process(target=self._test, args=(values,)) proc = self.Process(target=self._test, args=(values,))
proc.daemon = True
proc.start() proc.start()
proc.join() proc.join()
...@@ -928,6 +935,7 @@ class _TestArray(BaseTestCase): ...@@ -928,6 +935,7 @@ class _TestArray(BaseTestCase):
self.f(seq) self.f(seq)
p = self.Process(target=self.f, args=(arr,)) p = self.Process(target=self.f, args=(arr,))
p.daemon = True
p.start() p.start()
p.join() p.join()
...@@ -1332,6 +1340,7 @@ class _TestRemoteManager(BaseTestCase): ...@@ -1332,6 +1340,7 @@ class _TestRemoteManager(BaseTestCase):
manager.start() manager.start()
p = self.Process(target=self._putter, args=(manager.address, authkey)) p = self.Process(target=self._putter, args=(manager.address, authkey))
p.daemon = True
p.start() p.start()
manager2 = QueueManager2( manager2 = QueueManager2(
...@@ -1373,6 +1382,7 @@ class _TestManagerRestart(BaseTestCase): ...@@ -1373,6 +1382,7 @@ class _TestManagerRestart(BaseTestCase):
manager.start() manager.start()
p = self.Process(target=self._putter, args=(manager.address, authkey)) p = self.Process(target=self._putter, args=(manager.address, authkey))
p.daemon = True
p.start() p.start()
queue = manager.get_queue() queue = manager.get_queue()
self.assertEqual(queue.get(), 'hello world') self.assertEqual(queue.get(), 'hello world')
...@@ -1505,6 +1515,7 @@ class _TestConnection(BaseTestCase): ...@@ -1505,6 +1515,7 @@ class _TestConnection(BaseTestCase):
conn, child_conn = self.Pipe() conn, child_conn = self.Pipe()
p = self.Process(target=self._echo, args=(child_conn,)) p = self.Process(target=self._echo, args=(child_conn,))
p.daemon = True
p.start() p.start()
child_conn.close() # this might complete before child initializes child_conn.close() # this might complete before child initializes
...@@ -1577,6 +1588,7 @@ class _TestConnection(BaseTestCase): ...@@ -1577,6 +1588,7 @@ class _TestConnection(BaseTestCase):
conn, child_conn = self.Pipe(duplex=True) conn, child_conn = self.Pipe(duplex=True)
p = self.Process(target=self._writefd, args=(child_conn, b"foo")) p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
p.daemon = True
p.start() p.start()
with open(test.support.TESTFN, "wb") as f: with open(test.support.TESTFN, "wb") as f:
fd = f.fileno() fd = f.fileno()
...@@ -1600,6 +1612,7 @@ class _TestConnection(BaseTestCase): ...@@ -1600,6 +1612,7 @@ class _TestConnection(BaseTestCase):
conn, child_conn = self.Pipe(duplex=True) conn, child_conn = self.Pipe(duplex=True)
p = self.Process(target=self._writefd, args=(child_conn, b"bar", True)) p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
p.daemon = True
p.start() p.start()
with open(test.support.TESTFN, "wb") as f: with open(test.support.TESTFN, "wb") as f:
fd = f.fileno() fd = f.fileno()
...@@ -1688,11 +1701,13 @@ class _TestPicklingConnections(BaseTestCase): ...@@ -1688,11 +1701,13 @@ class _TestPicklingConnections(BaseTestCase):
lconn, lconn0 = self.Pipe() lconn, lconn0 = self.Pipe()
lp = self.Process(target=self._listener, args=(lconn0, families)) lp = self.Process(target=self._listener, args=(lconn0, families))
lp.daemon = True
lp.start() lp.start()
lconn0.close() lconn0.close()
rconn, rconn0 = self.Pipe() rconn, rconn0 = self.Pipe()
rp = self.Process(target=self._remote, args=(rconn0,)) rp = self.Process(target=self._remote, args=(rconn0,))
rp.daemon = True
rp.start() rp.start()
rconn0.close() rconn0.close()
...@@ -1830,6 +1845,7 @@ class _TestSharedCTypes(BaseTestCase): ...@@ -1830,6 +1845,7 @@ class _TestSharedCTypes(BaseTestCase):
string.value = latin('hello') string.value = latin('hello')
p = self.Process(target=self._double, args=(x, y, foo, arr, string)) p = self.Process(target=self._double, args=(x, y, foo, arr, string))
p.daemon = True
p.start() p.start()
p.join() p.join()
...@@ -1902,6 +1918,7 @@ class _TestFinalize(BaseTestCase): ...@@ -1902,6 +1918,7 @@ class _TestFinalize(BaseTestCase):
conn, child_conn = self.Pipe() conn, child_conn = self.Pipe()
p = self.Process(target=self._test_finalize, args=(child_conn,)) p = self.Process(target=self._test_finalize, args=(child_conn,))
p.daemon = True
p.start() p.start()
p.join() p.join()
...@@ -1971,12 +1988,16 @@ class _TestLogging(BaseTestCase): ...@@ -1971,12 +1988,16 @@ class _TestLogging(BaseTestCase):
reader, writer = multiprocessing.Pipe(duplex=False) reader, writer = multiprocessing.Pipe(duplex=False)
logger.setLevel(LEVEL1) logger.setLevel(LEVEL1)
self.Process(target=self._test_level, args=(writer,)).start() p = self.Process(target=self._test_level, args=(writer,))
p.daemon = True
p.start()
self.assertEqual(LEVEL1, reader.recv()) self.assertEqual(LEVEL1, reader.recv())
logger.setLevel(logging.NOTSET) logger.setLevel(logging.NOTSET)
root_logger.setLevel(LEVEL2) root_logger.setLevel(LEVEL2)
self.Process(target=self._test_level, args=(writer,)).start() p = self.Process(target=self._test_level, args=(writer,))
p.daemon = True
p.start()
self.assertEqual(LEVEL2, reader.recv()) self.assertEqual(LEVEL2, reader.recv())
root_logger.setLevel(root_level) root_logger.setLevel(root_level)
...@@ -2162,6 +2183,7 @@ def _ThisSubProcess(q): ...@@ -2162,6 +2183,7 @@ def _ThisSubProcess(q):
def _TestProcess(q): def _TestProcess(q):
queue = multiprocessing.Queue() queue = multiprocessing.Queue()
subProc = multiprocessing.Process(target=_ThisSubProcess, args=(queue,)) subProc = multiprocessing.Process(target=_ThisSubProcess, args=(queue,))
subProc.daemon = True
subProc.start() subProc.start()
subProc.join() subProc.join()
...@@ -2198,11 +2220,13 @@ class TestStdinBadfiledescriptor(unittest.TestCase): ...@@ -2198,11 +2220,13 @@ class TestStdinBadfiledescriptor(unittest.TestCase):
def test_queue_in_process(self): def test_queue_in_process(self):
queue = multiprocessing.Queue() queue = multiprocessing.Queue()
proc = multiprocessing.Process(target=_TestProcess, args=(queue,)) proc = multiprocessing.Process(target=_TestProcess, args=(queue,))
proc.daemon = True
proc.start() proc.start()
proc.join() proc.join()
def test_pool_in_process(self): def test_pool_in_process(self):
p = multiprocessing.Process(target=pool_in_process) p = multiprocessing.Process(target=pool_in_process)
p.daemon = True
p.start() p.start()
p.join() p.join()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment