diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-06-28 11:08:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 11:08:20 (GMT) |
commit | 38d6a40898940d2c62c637fcc8acce05e75de5c2 (patch) | |
tree | 2a2c720e141dbc0247a9d3a643ad6358d3615db2 /Lib/test | |
parent | e022aad73a4151b5628e2476a8465ce6c0d18b8c (diff) | |
download | cpython-38d6a40898940d2c62c637fcc8acce05e75de5c2.zip cpython-38d6a40898940d2c62c637fcc8acce05e75de5c2.tar.gz cpython-38d6a40898940d2c62c637fcc8acce05e75de5c2.tar.bz2 |
[3.6] Clear potential ref cycle between Process and Process target (GH-2470) (#2471)
* 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')
-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 e76c457..871a34e 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') @@ -398,6 +404,18 @@ class _TestProcess(BaseTestCase): p.join() self.assertTrue(wait_for_handle(sentinel, timeout=1)) + 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) + + # # # |