fix(tools): DaemonThreadPoolExecutor Python 3.14 compatibility - #59897
fix(tools): DaemonThreadPoolExecutor Python 3.14 compatibility#59897liuhao1024 wants to merge 1 commit into
Conversation
Python 3.14 reworked ThreadPoolExecutor internals: _replaced _initializer/_initargs attributes with WorkerContext changed _worker signature from (ref, work_queue, initializer, initargs) to (ref, ctx, work_queue) on 3.14+ This broke DaemonThreadPoolExecutor which mirrored the 3.8-3.13 implementation, causing AttributeError on every parallel tool call. Fix: runtime version probe (hasattr _create_worker_context). Use new API on 3.14+, fall back to old API on <3.14. Fixes NousResearch#59896
Duplicate of #57459 (earliest-open fix for the same Python 3.14 |
|
Closing this PR as a duplicate of #57459, which fixes the same Python 3.14 Both PRs address
The |
What does this PR do?
Fixes
DaemonThreadPoolExecutoron Python 3.14, where all parallel tool calls fail withAttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer'.Python 3.14 reworked
ThreadPoolExecutorinternals: it replaced the_initializer/_initargsattributes with aWorkerContextpattern and changed_worker's signature from(ref, work_queue, initializer, initargs)to(ref, ctx, work_queue).This PR adds a runtime version probe (
hasattr(self, "_create_worker_context")) and uses the new API on Python 3.14+ while falling back to the old API on older versions. The fix is minimal, focused on the single method that creates worker threads.Related Issue
Fixes #59896
Type of Change
Changes Made
tools/daemon_pool.py: Add runtime version probe in_adjust_thread_count(). Use_create_worker_context()on Python 3.14+, fall back to_initializer/_initargson <3.14.tests/tools/test_daemon_pool.py: Add regression testtest_initializer_args_passed_on_python_314_plus()to verify initializer args are correctly passed on both Python versions.How to Test
On Python 3.14 (or 3.13), run the new test:
Should pass with initializer called and task result correct.
Run full daemon pool test suite:
All 5 tests should pass.
Verify parallel tool calls work (e.g., batched
search_files,delegate_task):hermes "Run two search_files calls in parallel"Observed result: both calls execute successfully without AttributeError.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/tools/test_daemon_pool.py -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
This PR does not add a skill.
Screenshots / Logs
Test output: