fix(tools): make DaemonThreadPoolExecutor compatible with Python 3.14 - #81569
Closed
Ufonik88 wants to merge 1 commit into
Closed
fix(tools): make DaemonThreadPoolExecutor compatible with Python 3.14#81569Ufonik88 wants to merge 1 commit into
Ufonik88 wants to merge 1 commit into
Conversation
… worker context Python 3.14 refactored concurrent.futures.thread: ThreadPoolExecutor no longer sets self._initializer/_initargs — the initializer now lives in a WorkerContext created via _create_worker_context(), and _worker's signature became (executor_reference, ctx, work_queue). The old _adjust_thread_count passed self._initializer directly, so any concurrent tool batch (parallel skill_view/search_files/read_file/patch, cron job runs) raised: AttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer' Route worker args through _daemon_worker_args() which adapts to the running interpreter: 3.14+ builds a WorkerContext via _create_worker_context(); 3.8-3.13 keeps the (initializer, initargs) tuple, using getattr so missing attrs degrade safely. Verified with tests/tools/test_daemon_pool.py (3 passed) plus manual submit/initializer checks on Python 3.14.4.
Collaborator
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
DaemonThreadPoolExecutor._adjust_thread_count(used for parallel tool execution and subagent timeout wrappers) readsself._initializer/self._initargsdirectly. Python 3.14 refactoredconcurrent.futures.thread:ThreadPoolExecutor.__init__no longer stores those attributes — the initializer now lives in aWorkerContextproduced by_create_worker_context(), and_worker's signature became(executor_reference, ctx, work_queue).On 3.14 every concurrent tool batch fails at the first worker spawn:
This breaks any parallel tool batch (skill_view/search_files/read_file/patch fan-out, cron job runs, subagent submit) on interpreters where the venv resolved to Python 3.14.
Root cause
tools/daemon_pool.py,_adjust_thread_count— worker args tuple hard-codedself._initializer, self._initargs, which only exist on Python ≤3.13.Fix
Route worker args through a new
_daemon_worker_args()helper that adapts to the running interpreter:WorkerContextviaexecutor._create_worker_context()and pass(weakref, ctx, work_queue).(weakref, work_queue, initializer, initargs)tuple, usinggetattrso missing attrs degrade safely.All call sites (
tools/async_delegation.py,tools/skills_hub.py,tools/delegate_tool.py) share the one fixed class, so the whole bug class is covered.Verification
tests/tools/test_daemon_pool.py— 3 passed on Python 3.14.4 (the existing tests exercise worker spawn, which is exactly the failing path).initializer/initargson 3.14.4 — results correct, initializer runs once per worker.