diff options
| author | Victor Stinner <vstinner@redhat.com> | 2018-12-20 19:33:51 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-20 19:33:51 (GMT) |
| commit | 9a8d1d7562b11969034b92217fe66aab7a951fb6 (patch) | |
| tree | ef43389c6be139d7f016e98129c22bc829ea388c /Lib/test/_test_multiprocessing.py | |
| parent | c5d5dfdb223efb0e668e3f317d31b8b70ae96aa6 (diff) | |
| download | cpython-9a8d1d7562b11969034b92217fe66aab7a951fb6.zip cpython-9a8d1d7562b11969034b92217fe66aab7a951fb6.tar.gz cpython-9a8d1d7562b11969034b92217fe66aab7a951fb6.tar.bz2 | |
bpo-35424: emit ResourceWarning at multiprocessing.Pool destruction (GH-10974)
multiprocessing.Pool destructor now emits ResourceWarning
if the pool is still running.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
| -rw-r--r-- | Lib/test/_test_multiprocessing.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index b5597d5..7341131 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -2577,6 +2577,22 @@ class _TestPool(BaseTestCase): pass pool.join() + def test_resource_warning(self): + if self.TYPE == 'manager': + self.skipTest("test not applicable to manager") + + pool = self.Pool(1) + pool.terminate() + pool.join() + + # force state to RUN to emit ResourceWarning in __del__() + pool._state = multiprocessing.pool.RUN + + with support.check_warnings(('unclosed running multiprocessing pool', + ResourceWarning)): + pool = None + support.gc_collect() + def raising(): raise KeyError("key") |
