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:
2026-03-24 02:18:30 -04:00
parent 0db5dd126c
commit 9cd0de3883
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -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():