Skip to content

fix(tools): Python 3.14 compatibility for DaemonThreadPoolExecutor - #3

Open
djbclark wants to merge 1 commit into
mainfrom
fix/python-314-daemon-pool
Open

fix(tools): Python 3.14 compatibility for DaemonThreadPoolExecutor#3
djbclark wants to merge 1 commit into
mainfrom
fix/python-314-daemon-pool

Conversation

@djbclark

@djbclark djbclark commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Problem

Python 3.14 removed _initializer / _initargs from ThreadPoolExecutor.__init__, replacing them with _create_worker_context(). The _worker function signature also changed from 4 args to 3. DaemonThreadPoolExecutor._adjust_thread_count() still referenced the old API, causing:

AttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer'

This breaks read_file, search_files, skill_view, and other tools that use the thread pool for dispatch.

Fixes: NousResearch#69359, NousResearch#58596

Fix

Version-guarded branch that uses _create_worker_context() on Python 3.14+ (3-arg _worker) and the existing _initializer/_initargs path on Python 3.13- (4-arg _worker).

Why not the approach in NousResearch#57459?

PR NousResearch#57459 uses getattr(self, '_initializer', None) which avoids the AttributeError but still passes 4 args to _worker. On Python 3.14, _worker takes only 3 args — so it would fail with TypeError: _worker() takes 3 positional arguments but 4 were given.

Testing

  • ✅ Python 3.14.6: DaemonThreadPoolExecutor.submit(lambda: 42).result() returns 42
  • ✅ Python 3.13.14: same test passes
  • ✅ Live Hermes gateway (Python 3.14): read_file, search_files, skill_view all work after applying this patch

Migrated from upstream PR NousResearch#74452.

Python 3.14 removed _initializer / _initargs from ThreadPoolExecutor,
replacing them with _create_worker_context() and changing _worker() from
4 args to 3. DaemonThreadPoolExecutor._adjust_thread_count() still
referenced the old API, causing AttributeError on Python 3.14.

Add a version guard that uses the 3.14+ API when available and falls
back to the 3.13- API otherwise.

Fixes NousResearch#69359, obsoletes NousResearch#57459 (which used getattr fallback that still
passes the wrong number of args to 3.14's _worker).

Tested: passes on both Python 3.13 and 3.14.
djbclark pushed a commit that referenced this pull request Aug 11, 2026
… (re-review #3)

The last_activity_at/description/provenance columns already live in
SCHEMA_SQL and the column reconciler; existing DBs heal via the
reconciler, but the version stamp must advance so downgrade/upgrade
tooling sees the new layout. No version-literal test assertions exist
(tests compare against the imported constant).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DaemonThreadPoolExecutor crashes on Python 3.14 — AttributeError: "_initializer"

1 participant