diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-06-28 12:29:08 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-06-28 12:29:08 +0200 |
commit | 79d37ae979a65ada0b2ac820279ccc3b1cd41ba6 (patch) | |
tree | b1dabd3de47332efda05fa3f45e916b38b396912 /Lib/test/_test_multiprocessing.py | |
parent | a79f8faccf5e26f55e8b9496ad49d2071b5e299c (diff) | |
download | cpython-git-79d37ae979a65ada0b2ac820279ccc3b1cd41ba6.tar.gz |
Clear potential ref cycle between Process and Process target (#2470)
* 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
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 7dae3c498d..d0a5446cfe 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -191,6 +191,12 @@ def get_value(self): # Testcases # +class DummyCallable: + def __call__(self, q, c): + assert isinstance(c, DummyCallable) + q.put(5) + + class _TestProcess(BaseTestCase): ALLOWED_TYPES = ('processes', 'threads') @@ -469,6 +475,18 @@ class _TestProcess(BaseTestCase): for p in procs: self.assertEqual(p.exitcode, -signal.SIGTERM) + 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) + + # # # |