Dynamically added one-time tasks don't get executed by APScheduler

Viewed 107

In my Flask application, one route adds a job when it is called. This job doesn't get executed until the next time the Scheduler wakes up (e.g. when a repeating job would be scheduled). How can I make Flask-Apscheduler recalculate when to wake up upon dynamically adding a task?

    scheduler.add_job(func=test_func, args=('hello',), id=f"activate_{sn_deactivation.id}",
                  next_run_time=deactivate_until)

I am running my flask app with gunicorn and the preload app option to prevent creating multiple schedulers running the same jobs.

0 Answers
Related