-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Feature request: maxtasksperchild for ProcessPoolExecutor #88896
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
Comments
I love Documentation: "maxtasksperchild is the number of tasks a worker process can complete before it will exit and be replaced with a fresh worker process, to enable unused resources to be freed. The default maxtasksperchild is None, which means worker processes will live as long as the pool." I want to be able to set it to 1, so each process will only execute one task and then be replaced with a fresh process. |
I think I have a solution for this, but I'm pretty new to contributing. Still writing up some tests. |
Awesome. You can link to experimental code here. Even if it were not accepted to Python, it could be useful for me and for other people who might see this issue. |
bpo-46464 describes a deadlock that the pre-requisite for this feature causes. Spawning new children directly via fork() is impossible once a thread in the parent process has been started and concurrent.futures.process starts a thread. |
If we want this feature to stay in, it needs an implementation that does not rely on a multithreaded processing calling fork(). I'm going to have to revert the existing implementation for bpo-46464. |
Oh that sucks. Logan and Antoine worked on this feature for so long. Thanks for reporting Greg. |
Based on my reading I’m hopeful that this change can make it in quickly once I find the time. The previous implementation didn’t care how the processes were created. I will look as soon as I can |
from discussion on the other bug it looks like we should have a way to keep this; we just need to not allow it when the mp_context to be used is the 'fork' one. |
As this is a new feature, it would also be reasonable to have specifying max_tasks_per_child without explicitly specifying a mp_context default to a safe mp_context. |
Okay, I'm actually able to work on this again. What is the best way to make this change real. Should I be working off of main? |
yep, branch off of a recent main. |
Ok I now have a PR up with the features requested. Let me know if you need anything else! |
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: