Repository navigation
fix(npu-workers): await _save_workers_to_config in _load_workers_from_config (#12526) - #12533
Merged
Merged
Conversation
…_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.
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
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.
Thinking Path
_load_workers_from_config(sync) called the async_save_workers_to_configwithoutawaiton the config-missing branch — the coroutine was created and immediately garbage-collected (silent no-op +RuntimeWarning: coroutine ... was never awaited). It ran viaasyncio.to_thread(self._load_workers_from_config)from_initialize_impl, i.e. on a worker thread with no running event loop, so simply addingawaitin place wouldn't have worked — the whole call chain needed to become async so it runs on the event loop whereawaitis 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 correctlyawaitit. The only other bare-looking calls (_health_check_loop,failover_monitor,_pulse_probe_loop) are wrapped inasyncio.create_task(...)(intentional background tasks) and_get_worker_statusinsideasyncio.gather(...)(correctly awaited by gather) — no other bugs found in this file.What Changed
autobot-backend/services/npu_worker_manager.py:_load_workers_from_configis nowasync defand directlyawait self._save_workers_to_config()on the missing-file branch._initialize_implnow doesawait self._load_workers_from_config()directly instead ofasyncio.to_thread(self._load_workers_from_config).Path.exists(),open()+yaml.safe_load()) is still kept off the event loop viaasyncio.to_thread, extracted into a small_read_config_filehelper — same pattern_save_workers_to_configalready uses formkdir.autobot-backend/services/test_npu_worker_config_load_12526.py(new): regression tests covering_initialize_implawaits_load_workers_from_config.Verification
No
RuntimeWarning: coroutine ... was never awaited(elevated to a hard error via-W error::RuntimeWarningand the run still passed).Closes #12526
Model Used
Claude Sonnet 5