Repository navigation
Implement max_tasks_per_child for process and reusable executors - #685
Open
Aschenbath wants to merge 2 commits into
Open
Aschenbath wants to merge 2 commits into
Aschenbath wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workers in long-running pools can accumulate memory or native state across many calls. Add an opt-in
max_tasks_per_childlimit toProcessPoolExecutorandget_reusable_executor, replacing workers after that many completed calls while preserving pending futures. The defaultNonekeeps the existing unlimited behavior.Each submitted call counts once, including calls that raise or produce an unpicklable result. Each
mapchunk counts once; cancellation and argument serialization failures in the parent do not consume a worker's allowance. The initializer runs in each replacement, and changing the limit recreates a reusable executor underreuse="auto". The option supports loky, spawn and forkserver, and rejects fork.Worker startup state remains available to the manager after asynchronous shutdown or executor collection. The existing exit handshake handles retirement, nested cleanup stays interruptible by
kill_workers=True, and requested resize exits are distinguished from genuine timeout and memory warnings.Validation:
--skip-high-memoryreports 368 passed, 25 skipped and 3 failures. All three reproduce on the unchanged base: BusyBoxlsofoutput differs from the expected format; the Docker Desktop WSL distribution rejects the Docker CLI used by the cgroup test; and this musl runtime does not reject a bounded-semaphore over-release.git diff --checkpass.-Wreports the same 13 existing diagnostics on the changed source and unchanged base; there are no new diagnostics.Closes #373.
AI assistance: OpenAI Codex prepared this change, tests and description. Separate automated agents reviewed the implementation and ran independent probes; this is not human maintainer review.