-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-38501: Add a warning section to multiprocessing.Pool docs about resource managing #19466
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
Conversation
|
||
Note that is **not correct** to rely on the garbage colletor to destroy the pool | ||
as CPython does not assure that the finalizer of the pool will be called | ||
(see :meth:`object.__del__` for more information). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My potential fix is to use atexit.register
when we can't use the context manager. Worth suggesting here? (Also let me know if it's clearly a bad idea for some reason!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My potential fix is to use
atexit.register
when we can't use the context manager. Worth suggesting here? (Also let me know if it's clearly a bad idea for some reason!)
That works, but the problem is that is still a lossy method of resource managing (you would not use that method for all your file objects for instance). Technically, someone that is not "the interpreter" should own the pool and should be in charge of destroying it correctly.
I understand that some architecture and designs make this challenging so things like atexit
do work for those cases, but I think is better not to explicitly mention that here so users don't start to use that as a silver bullet and use more the context manager for instance.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense. Otherwise, text LGTM and reads nicely in the rendered artifact!
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8. |
…esource managing (pythonGH-19466) (cherry picked from commit 7ec43a7) Co-authored-by: Pablo Galindo <[email protected]>
GH-19467 is a backport of this pull request to the 3.8 branch. |
…esource managing (pythonGH-19466) (cherry picked from commit 7ec43a7) Co-authored-by: Pablo Galindo <[email protected]>
GH-19468 is a backport of this pull request to the 3.7 branch. |
…esource managing (GH-19466) (cherry picked from commit 7ec43a7) Co-authored-by: Pablo Galindo <[email protected]>
…esource managing (GH-19466) (cherry picked from commit 7ec43a7) Co-authored-by: Pablo Galindo <[email protected]>
https://bugs.python.org/issue38501