mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-35424: emit ResourceWarning at multiprocessing.Pool destruction (GH-10974)
multiprocessing.Pool destructor now emits ResourceWarning if the pool is still running.
This commit is contained in:
parent
c5d5dfdb22
commit
9a8d1d7562
3 changed files with 36 additions and 5 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue