-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Leaked semaphore objects in test_concurrent_futures #104090
Comments
The leakage is from |
Two failing tests:
|
(reduced the output so it will be clearer)
|
Ok, found more - This line creates a new queue with 3 semaphore related and when the
Still investigating |
For some additional context, I also ran
is completely commented out:
Another thing that I found interesting was the leaked semaphore objects look like
However, I'm not sure about this, since it does not look like cpython/Lib/test/test_concurrent_futures.py Lines 1248 to 1249 in 89867d2
|
Not related to TemporaryFile, those are virtual files used by each semaphore object as the system locking mechanisem
Source: https://linux.die.net/man/7/sem_overview For example, if you stop the process in the middle you will be able to see those virtual files here which will be deleted on |
Ok, found how to fix the issue! 🚀 Full detailsThe current code calls This causes the 3 sempahors of Example 1 (without
|
Hey, Found better solution and also what's happening here. The reason those 3 semaphores were still alive and not deleted, it's because there weren't garabage collected yet, since they have a reference. How? Those 3 semaphors are related to This mixin is used to create the test class Why we need the test object there? For displaying it on So how to fix it? Very simple, instead of passing the test object, we just need here the test repr only! if hasattr(self, "collectedDurations"):
self.collectedDurations.append((str(test), elapsed)) And this works perfect! 🚀 I'll create a PR for this |
Good find! |
…rent_futures-debug-session' into pythongh-104090-fix-leaked-semaphors-on-test_concurrent_futures
…-leaked-semaphors-on-test_concurrent_futures
…-leaked-semaphors-on-test_concurrent_futures
…_futures' of github.com:bityob/cpython into pythongh-104090-fix-leaked-semaphors-on-test_concurrent_futures
…_concurrent_futures-v2
…_concurrent_futures-v2
…_concurrent_futures
…_concurrent_futures-v2
…onGH-106795) (cherry picked from commit 70b961e) Co-authored-by: Yonatan Bitton <[email protected]>
…onGH-106795) (cherry picked from commit 70b961e) Co-authored-by: Yonatan Bitton <[email protected]>
…_concurrent_futures-v2
…_futures-v2' of github.com:bityob/cpython into pythongh-104090-fix-leaked-semaphors-on-test_concurrent_futures-v2
…_concurrent_futures-v2
…_concurrent_futures-v2
…_futures-v2' of github.com:bityob/cpython into pythongh-104090-fix-leaked-semaphors-on-test_concurrent_futures-v2
…_concurrent_futures-v2
…_concurrent_futures-v2
This builds on #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 <[email protected]> Co-authored-by: Yonatan Bitton <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
That PR was a helper to make failures like this easier to diagnose. |
…thonGH-115410) This builds on python#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 <[email protected]> Co-authored-by: Yonatan Bitton <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
I get the same error in my case. I'm doing distributed training using spawn multiprocessing and DDP, also at the end of running my application I get a specific number of leaked semaphores. This is the link of the issue. I'm wondering if this issue is solved or not. |
…thonGH-115410) This builds on python#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 <[email protected]> Co-authored-by: Yonatan Bitton <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
Bug report
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: