Skip to content

Fix semaphore leak #1677

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

vinnik-dmitry07
Copy link

/root/.pyenv/versions/3.12.11/lib/python3.12/multiprocessing/resource_tracker.py:279: 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 '

and

Exception in thread Thread-2:
Exception in threading.excepthook:
Exception ignored in thread started by: <bound method Thread._bootstrap of <TMonitor(Thread-2, started daemon 132951006242368)>>
Exception ignored in sys.unraisablehook: <built-in function unraisablehook>

Both errors happen when the program stop normally or after error.
Python garbage collector is seems to be not smart enough to clean memory after dynamic class property assignment.
TMonitor is also not released properly because of async code.
This is the minimal irreducible change.

apple/ml-stable-diffusion#8
https://www.reddit.com/r/comfyui/comments/1c0n5de/there_appear_to_be_1_leaked_semaphore_objects_to/
https://discuss.python.org/t/leaked-semaphore-objects-to-clean-up-error-when-using-concurrent-futures/54510
modelscope/ms-swift#4689
https://github.com/search?q=%22UserWarning%3A+resource_tracker%3A+There+appear+to+be+1+leaked+semaphore+objects+to+clean+up+at+shutdown%22+tqdm&type=issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant