Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprocessing.Pool: leak of global named resources using multiprocessing spawn #122770

Open
vindex10 opened this issue Aug 7, 2024 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@vindex10
Copy link

vindex10 commented Aug 7, 2024

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

@vindex10 vindex10 added the type-bug An unexpected behavior, bug, or error label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant