mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-104090: Add exit code to multiprocessing ResourceTracker (GH-115410)
This builds on https://github.com/python/cpython/pull/106807, which adds a return code to ResourceTracker, to make future debugging easier. Testing this “in situ” proved difficult, since the global ResourceTracker is involved in test infrastructure. So, the tests here create a new instance and feed it fake data. --------- Co-authored-by: Yonatan Bitton <yonatan.bitton@perception-point.io> Co-authored-by: Yonatan Bitton <bityob@gmail.com> Co-authored-by: Antoine Pitrou <antoine@python.org>
This commit is contained in:
parent
b052fa381f
commit
4a9e6497c2
4 changed files with 94 additions and 7 deletions
|
@ -3,6 +3,7 @@ import logging
|
|||
import queue
|
||||
import time
|
||||
import unittest
|
||||
import sys
|
||||
from concurrent.futures._base import BrokenExecutor
|
||||
from logging.handlers import QueueHandler
|
||||
|
||||
|
@ -109,6 +110,31 @@ create_executor_tests(globals(), InitializerMixin)
|
|||
create_executor_tests(globals(), FailingInitializerMixin)
|
||||
|
||||
|
||||
@unittest.skipIf(sys.platform == "win32", "Resource Tracker doesn't run on Windows")
|
||||
class FailingInitializerResourcesTest(unittest.TestCase):
|
||||
"""
|
||||
Source: https://github.com/python/cpython/issues/104090
|
||||
"""
|
||||
|
||||
def _test(self, test_class):
|
||||
runner = unittest.TextTestRunner()
|
||||
runner.run(test_class('test_initializer'))
|
||||
|
||||
# GH-104090:
|
||||
# Stop resource tracker manually now, so we can verify there are not leaked resources by checking
|
||||
# the process exit code
|
||||
from multiprocessing.resource_tracker import _resource_tracker
|
||||
_resource_tracker._stop()
|
||||
|
||||
self.assertEqual(_resource_tracker._exitcode, 0)
|
||||
|
||||
def test_spawn(self):
|
||||
self._test(ProcessPoolSpawnFailingInitializerTest)
|
||||
|
||||
def test_forkserver(self):
|
||||
self._test(ProcessPoolForkserverFailingInitializerTest)
|
||||
|
||||
|
||||
def setUpModule():
|
||||
setup_module()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue