Skip to content

fix(npu-workers): await _save_workers_to_config in _load_workers_from_config (#12526) - #12533

Merged
mrveiss merged 1 commit into
Dev_new_guifrom
issue-12526
Jul 25, 2026
Merged

mrveiss merged 1 commit into
Dev_new_guifrom
issue-12526

Conversation

@mrveiss

@mrveiss mrveiss commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Thinking Path

_load_workers_from_config (sync) called the async _save_workers_to_config without await on the config-missing branch — the coroutine was created and immediately garbage-collected (silent no-op + RuntimeWarning: coroutine ... was never awaited). It ran via asyncio.to_thread(self._load_workers_from_config) from _initialize_impl, i.e. on a worker thread with no running event loop, so simply adding await in place wouldn't have worked — the whole call chain needed to become async so it runs on the event loop where await is meaningful.

Checked all other self._<name>( call sites against the async-method set in the file: the other 4 _save_workers_to_config() calls (add_worker, update_worker, remove_worker, update_load_balancing_config) already correctly await it. The only other bare-looking calls (_health_check_loop, failover_monitor, _pulse_probe_loop) are wrapped in asyncio.create_task(...) (intentional background tasks) and _get_worker_status inside asyncio.gather(...) (correctly awaited by gather) — no other bugs found in this file.

What Changed

  • autobot-backend/services/npu_worker_manager.py:
    • _load_workers_from_config is now async def and directly await self._save_workers_to_config() on the missing-file branch.
    • _initialize_impl now does await self._load_workers_from_config() directly instead of asyncio.to_thread(self._load_workers_from_config).
    • Blocking file I/O (Path.exists(), open() + yaml.safe_load()) is still kept off the event loop via asyncio.to_thread, extracted into a small _read_config_file helper — same pattern _save_workers_to_config already uses for mkdir.
  • autobot-backend/services/test_npu_worker_config_load_12526.py (new): regression tests covering
    • missing config file → save is awaited (mocked) and, separately, an end-to-end run where the file is actually written (the real regression check — previously this file was never created).
    • existing config file → save is not invoked.
    • _initialize_impl awaits _load_workers_from_config.

Verification

$ python3 -W error::RuntimeWarning -m pytest services/test_npu_worker_config_load_12526.py \
    services/test_npu_worker_events.py services/npu_worker_manager_pulse_test.py -p no:xdist -q
28 passed in 0.44s

No RuntimeWarning: coroutine ... was never awaited (elevated to a hard error via -W error::RuntimeWarning and the run still passed).

$ python3 -m black --check autobot-backend/services/npu_worker_manager.py autobot-backend/services/test_npu_worker_config_load_12526.py
All done! 2 files would be left unchanged.
$ python3 -m flake8 --max-line-length=120 autobot-backend/services/npu_worker_manager.py autobot-backend/services/test_npu_worker_config_load_12526.py
(no output — clean)

Closes #12526

Model Used

Claude Sonnet 5

…_config (#12526)

_load_workers_from_config called the async _save_workers_to_config
without awaiting it when the config file was missing, silently
discarding the coroutine (RuntimeWarning: coroutine was never
awaited). Made _load_workers_from_config async and awaited the save
directly; blocking file I/O is offloaded via asyncio.to_thread instead
of wrapping the whole (now-async) method, matching the pattern already
used at the other 4 _save_workers_to_config call sites.
@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

@mrveiss
mrveiss merged commit 2fcc08c into Dev_new_gui Jul 25, 2026
39 checks passed
@mrveiss
mrveiss deleted the issue-12526 branch July 25, 2026 22:25
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.

1 participant