fix(briefing): deadlock in scheduler startup
start_briefing_scheduler was called from before_serving (event loop thread) and used run_coroutine_threadsafe(...).result() which blocks the calling thread waiting for the coroutine to complete — but since the calling thread IS the event loop, the coroutine could never run, causing a 10s timeout and zero jobs scheduled. Fix: make start_briefing_scheduler async and await _get_briefing_enabled_users() directly. Also use asyncio.create_task for the catch-up rather than run_coroutine_threadsafe. The background thread jobs (_run_user_slot_sync) continue to use run_coroutine_threadsafe correctly since they run on the APScheduler thread, not the event loop thread. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -246,7 +246,7 @@ def create_app() -> Quart:
|
||||
|
||||
# Start briefing scheduler
|
||||
from fabledassistant.services.briefing_scheduler import start_briefing_scheduler
|
||||
start_briefing_scheduler(asyncio.get_running_loop())
|
||||
await start_briefing_scheduler(asyncio.get_running_loop())
|
||||
|
||||
@app.after_serving
|
||||
async def shutdown():
|
||||
|
||||
Reference in New Issue
Block a user