Merged
Conversation
Add Python 3.14t (free-threaded, no-GIL) to the CI matrix with PYTHON_GIL=0 to ensure the GIL stays disabled during testing. Fix several thread-safety issues in pool management that were previously hidden by the GIL: - Protect busy_workers set with a lock (concurrent add/remove/len from multiple run_task threads) - Protect existing_workers and running_futs WeakSets (not thread-safe without GIL) - Fix max_workers_busy_concurrently race condition (read-then-write without holding the stat's lock) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The free-threaded build installs as python3.14t, not python3.14, so nox can't find it via its default discovery. Use --force-python to tell nox to use the current interpreter directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Nox >= 2025.10.14 supports 3.14t in session python lists natively, so add it to the nox sessions and use nox -s testcov-3.14t directly instead of working around the interpreter discovery. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test expected exactly 11 unique PIDs, but PID recycling can cause a replaced worker to get the same PID as its predecessor, reducing the count. Use >= 10 which still proves worker replacement is happening while tolerating occasional PID reuse. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
PYTHON_GIL=0to ensure the GIL stays disabled during testingbusy_workersset accessed from multiplerun_taskthreads without synchronizationexisting_workersandrunning_futsWeakSets (not thread-safe without GIL)max_workers_busy_concurrentlystat had a read-then-write race conditionAll fixes use a single
_workers_locksince the protected operations are brief and closely related.tasks_ran_counterandworker.okwere analyzed and found to be single-owner (eachWorkerProcessis exclusively held by one thread at a time), so no locks needed there.Test plan
SyntaxWarningon import with 3.14tpsutilandsetproctitleboth havecp314twheels