[bug] Fix the problem where the job scheduler isn't scheduling the jobs #309

Closed
opened 2025-11-26 15:18:04 +01:00 by Ghost · 0 comments
Ghost commented 2025-11-26 15:18:04 +01:00 (Migrated from codeberg.org)
/usr/local/lib/python3.11/concurrent/futures/thread.py:85: RuntimeWarning: coroutine 'schedule_jobs' was never awaited
  del work_item

I noticed the error above, so I imagine that's the issue. After I made the 'schedule_jobs' method async, I had claude review it:

Yes, this is a legitimate fix!

Your changes are correct. Here's why:

  1. Root Cause: schedule_jobs() was declared as async def but none of its internal calls (schedule_nag_players(), schedule_update_games(), etc.) are async functions - they're all synchronous.
  2. Your Fix: You correctly changed:
    - async def schedule_jobs() → def schedule_jobs() in app/jobs/scheduler.py:144
    - await schedule_jobs() → schedule_jobs() in app/main.py:70
    - async def job_schedule_jobs() → def job_schedule_jobs() in app/routers/admin.py:53
  3. Why This Works: Since all the scheduling functions inside schedule_jobs() are synchronous (they just register jobs with APScheduler), there's no need for the function to be async. Making it
    synchronous eliminates the warning about an unawaited coroutine.

The fix properly aligns the function signature with its implementation. The RuntimeWarning was occurring because somewhere in the execution flow (likely in the threadpool executor used by APScheduler),
the async function was being called without being awaited.

Your changes look good to commit! 👍

``` /usr/local/lib/python3.11/concurrent/futures/thread.py:85: RuntimeWarning: coroutine 'schedule_jobs' was never awaited del work_item ``` I noticed the error above, so I imagine that's the issue. After I made the 'schedule_jobs' method async, I had claude review it: Yes, this is a legitimate fix! ✅ Your changes are correct. Here's why: 1. Root Cause: schedule_jobs() was declared as async def but none of its internal calls (schedule_nag_players(), schedule_update_games(), etc.) are async functions - they're all synchronous. 2. Your Fix: You correctly changed: - async def schedule_jobs() → def schedule_jobs() in app/jobs/scheduler.py:144 - await schedule_jobs() → schedule_jobs() in app/main.py:70 - async def job_schedule_jobs() → def job_schedule_jobs() in app/routers/admin.py:53 3. Why This Works: Since all the scheduling functions inside schedule_jobs() are synchronous (they just register jobs with APScheduler), there's no need for the function to be async. Making it synchronous eliminates the warning about an unawaited coroutine. The fix properly aligns the function signature with its implementation. The RuntimeWarning was occurring because somewhere in the execution flow (likely in the threadpool executor used by APScheduler), the async function was being called without being awaited. Your changes look good to commit! 👍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
johnsturgeon/tgfp-web#309
No description provided.