Fix periodic config update crash under Twisted asyncio reactor - #69
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe configuration updater now logs unexpected failures, runs through a dedicated asyncio task wrapped in a Twisted Deferred, and uses this scheduling entry point for periodic daemon updates. ChangesConfiguration update scheduling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Periodic configuration updates now run in an asyncio task and log unexpected failures so later update attempts continue. No concrete merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant LoopingCall
participant schedule_update_config
participant asyncio
participant update_config
participant Deferred
LoopingCall->>schedule_update_config: Start periodic update
schedule_update_config->>asyncio: Create task for update_config
asyncio->>update_config: Run configuration update
schedule_update_config->>Deferred: Wrap task future
Deferred-->>LoopingCall: Return Deferred
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b4bb25b to
07f9f99
Compare
LoopingCall invoked update_config() directly as an async coroutine, which Twisted ran through its deferred/coroutine bridge. When get_distro_packages() retried via tenacity during dynamic config reload, await on tenacity's asyncio.sleep() failed with RuntimeError: await wasn't used with future because the retry slept outside a proper asyncio task. Add schedule_update_config() as the LoopingCall entry point; it returns Deferred.fromFuture(asyncio.ensure_future(update_config())) so the full update path (including Content Resolver fetches and tenacity retries) runs in a dedicated asyncio task, matching the pattern used in web.py. Fixes: fedora-eln#68 Co-authored-by: Cursor <cursoragent@cursor.com>
Periodic config reload could raise outside the known UnknownRefError and ConfigError paths (for example tenacity/asyncio integration bugs or network faults during Content Resolver fetches). Those exceptions propagated out of update_config(), producing "Unhandled error in Deferred" and leaving the config LoopingCall in a failed state with no further scheduled updates. Wrap the body of update_config() in a catch-all handler that logs the traceback, records a critical message that the timer will retry, and returns normally so schedule_update_config() completes and the LoopingCall continues on its interval.
07f9f99 to
4565e57
Compare
Fix periodic config update crash under Twisted asyncio reactor.
LoopingCall invoked update_config() directly as an async coroutine, which
Twisted ran through its deferred/coroutine bridge. When get_distro_packages()
retried via tenacity during dynamic config reload, await on tenacity's
asyncio.sleep() failed with RuntimeError: await wasn't used with future
because the retry slept outside a proper asyncio task.
Add schedule_update_config() as the LoopingCall entry point; it returns
Deferred.fromFuture(asyncio.ensure_future(update_config())) so the full
update path (including Content Resolver fetches and tenacity retries) runs
in a dedicated asyncio task, matching the pattern used in web.py.
Co-authored-by: Cursor cursoragent@cursor.com
Catch unexpected errors in update_config() so LoopingCall keeps running.
Periodic config reload could raise outside the known UnknownRefError and
ConfigError paths (for example tenacity/asyncio integration bugs or network
faults during Content Resolver fetches). Those exceptions propagated out of
update_config(), producing "Unhandled error in Deferred" and leaving the
config LoopingCall in a failed state with no further scheduled updates.
Wrap the body of update_config() in a catch-all handler that logs the
traceback, records a critical message that the timer will retry, and returns
normally so schedule_update_config() completes and the LoopingCall continues
on its interval.
Summary by CodeRabbit