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

resource_tracker: There appear to be 32 leaked semaphore objects to clean up at shutdown #27

Closed
sailxjx opened this issue Dec 1, 2021 · 5 comments · Fixed by #119
Closed
Assignees
Labels
bug Something isn't working

Comments

@sailxjx
Copy link

sailxjx commented Dec 1, 2021

I've got this message by resource tracker when I use spawn mode on my mac, the code is really simple:

import time
from mpire import WorkerPool


def global_runner(*args):
    print("I am Running", args)
    time.sleep(0.3)
    return


if __name__ == "__main__":
    params_group = [1, 2]
    with WorkerPool(n_jobs=2, start_method="spawn") as pool:
        pool.map(global_runner, params_group)

Screen Shot 2021-12-01 at 17 19 32

Can anyone help me solve this problem?

@sailxjx
Copy link
Author

sailxjx commented Dec 1, 2021

The version of python is 3.9.7

@sybrenjansen
Copy link
Owner

Hmm.. Unfortunately I don't have a mac to be able to debug this. When testing this on linux using python 3.9.7 your script works just fine and doesn't give the warnings. So it's probably mac specific.

However, it is only a warning at the end of the script, and a warning like this can be safely ignored. I.e., your code should still work fine.

If someone else wants to do some debugging, please do so. The only semaphores being used in mpire are within JoinableQueues in mpire/comms.py.

@sybrenjansen sybrenjansen added the help wanted Extra attention is needed label Dec 6, 2021
@macintacos
Copy link

Don't ask me how, but I seem to be consistently getting this when using a WorkerPool with progress_bar=True. When I remove the progress bar (and remove start_method="spawn") the issue goes away.

@jonashaag
Copy link
Contributor

There is definitely a bug here that leaks semaphores. It causes macOS to run out of file descriptors.

@sybrenjansen sybrenjansen added bug Something isn't working and removed help wanted Extra attention is needed labels Jan 28, 2024
@sybrenjansen sybrenjansen self-assigned this Jan 28, 2024
@sybrenjansen
Copy link
Owner

Bug has been found. Mac support will be added soon

sybrenjansen added a commit that referenced this issue Jan 31, 2024
  - Fixes memory leaks on macOS
  - Reduced the amount of semaphores used
  - Issues a warning when ``cpu_ids`` is used on macOS

Fixes #27
Fixes #79
Fixes #91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants