Skip to content

fix(tools): support Python 3.14 worker context in DaemonThreadPoolExecutor (#76621) - #76756

Closed
Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/76621-daemon-pool-py314
Closed

fix(tools): support Python 3.14 worker context in DaemonThreadPoolExecutor (#76621)#76756
Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/76621-daemon-pool-py314

Conversation

@Enough1122

Copy link
Copy Markdown
Contributor

Summary

DaemonThreadPoolExecutor._adjust_thread_count mirrors CPython 3.8–3.13's ThreadPoolExecutor implementation and reads self._initializer / self._initargs. CPython 3.14 removed those attributes in favor of _create_worker_context() (and changed _worker's signature to (executor_reference, ctx, work_queue)), so the first parallel tool batch on Python 3.14 crashed with AttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer'.

Fix: branch on hasattr(self, '_create_worker_context') — on 3.14+ pass the context object to _worker; on 3.8–3.13 the existing path is unchanged.

Single-file change (plus one new test). No public API change. No new imports.

NOT doing X: not touching shutdown/idle-reuse semantics — daemon workers and _threads_queues skip are preserved on both branches.

Test plan

python -m pytest tests/tools/test_daemon_pool.py -q
# 4 passed (3 existing + 1 new: simulates the 3.14 layout via a fake
# _create_worker_context and asserts the Thread constructor receives
# (executor_ref, ctx, work_queue) with daemon=True)

Verified on Python 3.11 (3.8–3.13 branch). The 3.14 branch is exercised by the new unit test without depending on a 3.14 interpreter.

…cutor (NousResearch#76621)

CPython 3.14 removed ThreadPoolExecutor._initializer/_initargs in favor
of _create_worker_context(); the _worker signature became
(executor_reference, ctx, work_queue). _adjust_thread_count read the
removed attributes, so the first parallel tool batch crashed on 3.14.

Branch on hasattr(self, '_create_worker_context') and pass the context
object on 3.14+, keeping the 3.8-3.13 path unchanged.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades duplicate This issue or pull request already exists labels Aug 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #57459: both patches repair the Python 3.14 WorkerContext / _worker contract in DaemonThreadPoolExecutor._adjust_thread_count.

@teknium1

teknium1 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the focused compatibility repair. Current main still builds daemon workers with the legacy four-element tuple at tools/daemon_pool.py:55-60; CPython 3.14 defines _worker(executor_reference, ctx, work_queue) in Lib/concurrent/futures/thread.py:97 and creates that context in its executor implementation. The new branch supplies that exact three-element tuple while preserving the legacy path.

Problems

Suggested changes

This is an automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Aug 2, 2026
@Enough1122

Copy link
Copy Markdown
Contributor Author

Duplicate — 5 existing open PRs cover the same daemon_pool 3.14 worker-contract fix (#65182/#70873/#61224/#63780/#63777), and #76621 is itself a duplicate of #58596. Closing mine in favor of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants