summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-06-28 11:48:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-06-28 11:48:38 (GMT)
commit12536bd261ba95cd2748f3d7d47768742a6ffa7a (patch)
tree45779e08286b61b38b36c9eb408ace8c5cabe085 /Lib/test/test_multiprocessing.py
parent5b5002c466f7952a81634e482d1aa9ef0f3e96f7 (diff)
downloadcpython-12536bd261ba95cd2748f3d7d47768742a6ffa7a.zip
cpython-12536bd261ba95cd2748f3d7d47768742a6ffa7a.tar.gz
cpython-12536bd261ba95cd2748f3d7d47768742a6ffa7a.tar.bz2
[2.7] Clear potential ref cycle between Process and Process target (GH-2470) (#2473)
* Clear potential ref cycle between Process and Process target Besides Process.join() not being called, this was an indirect cause of bpo-30775. The threading module already does this. * Add issue reference. (cherry picked from commit 79d37ae979a65ada0b2ac820279ccc3b1cd41ba6)
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 9fcd3bd..69bd8f7 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -175,6 +175,12 @@ def get_value(self):
# Testcases
#
+class DummyCallable(object):
+ def __call__(self, q, c):
+ assert isinstance(c, DummyCallable)
+ q.put(5)
+
+
class _TestProcess(BaseTestCase):
ALLOWED_TYPES = ('processes', 'threads')
@@ -355,6 +361,18 @@ class _TestProcess(BaseTestCase):
p.join(5)
self.assertEqual(p.exitcode, reason)
+ def test_lose_target_ref(self):
+ c = DummyCallable()
+ wr = weakref.ref(c)
+ q = self.Queue()
+ p = self.Process(target=c, args=(q, c))
+ del c
+ p.start()
+ p.join()
+ self.assertIs(wr(), None)
+ self.assertEqual(q.get(), 5)
+
+
#
#
#