-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Add multiprocessing.queues.SimpleQueue.close() #75149
Comments
multiprocessing.queues.SimpleQueue should have a close() method. This is needed to explicitly release the two file descriptors of the Pipe used internally. Without it, the file descriptors leak if a reference to the SimpleQueue object happens to stay around for longer than expected (e.g. in a reference cycle, or with PyPy). I think the following would do: diff -r 0b72fd1a7641 lib-python/2.7/multiprocessing/queues.py + def close(self): |
Get this solved then we could also solve bpo-23267, which reports pipes leak in pool due to using SimpleQueue. |
On Python 3.6+, regrtest is able to detect file descriptor leaks when using --huntrleaks. Is someone interested to backport this feature to 3.5 and/or 2.7 which would mean fix all FD leaks in our test suite? If someone wants to work on that, I would suggest to first fix all bugs, and when the test suite is fine: modify regrtest. |
See also my bpo-30171: "Emit ResourceWarning in multiprocessing Queue destructor". |
This issue is marked as also affecting Python 3.7. I don't see a SimpleQueue.close() method in master, but I don't remind any resource warning when running tests on master neither. Does it mean that our test runner miss such file descriptor leak? Or worse, that SimpleQueue is not tested? I see a TestSimpleQueue test case in Lib/test/_test_multiprocessing.py. haypo@selma$ ./python -m test test_multiprocessing_spawn -m TestSimpleQueue -R 3:3
Oh ok, the garbage collector is able to close the file descriptors. The bug is when a SimpleQueue is not collected. So again, I consider that a ResourceWarning is needed here. The purpose of a ResourceWarning is to warn when a leak may be kept alive longer than expected if it's not closed explicitly. |
Anyone who thinks those objects stay alive too long can submit a PR for SimpleQueue and Pool to close them eagerly. |
I started with SimpleQueue for the master branch: |
bpo-23267 is marked as a duplicate of this issue. |
This seems complete, can it be closed? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: