Open
Description
Bug report
Bug description:
I'm receiving a warning when using the multiprocessing.Pool
in spawn
mode.
/opt/pyenv/versions/3.12.4/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
A similar issue was brought up and fixed before, when multiprocessing.Process
was used:
#30617
The test case introduced by the PR above: https://github.com/python/cpython/blob/3.12/Lib/test/_test_multiprocessing.py#L6040C7-L6040C24
To trigger the warning, I just replaced the Process
with Pool
as follows:
import multiprocessing as mp
ctx = mp.get_context('spawn')
global_resource = ctx.Semaphore()
def submain(): pass
if __name__ == '__main__':
p = ctx.Pool(processes=3).starmap(submain, [tuple() for i in range(5)])
CPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Linux