pythonapscheduler

Apscheduler are just running once when I set daily


I need a daily function trigger with APSscheduler setting. However, APS scheduler just can trigger once. As I showed with my code, I set 21:00 trigger every day, but it can only trigger with the first 21:00.

#!/usr/bin/env python

from apscheduler.schedulers.background import BackgroundScheduler

# Running Timer
scheduler = BackgroundScheduler(timezone='asia/taipei')


def push_today():
    # Running with my triggered code

def entry_point(upgrade_hint):    
    scheduler.add_job(push_today, 'cron', year='*', month='*', day="*", hour=21, minute=0, second=0)
    scheduler.start()

    # Flask app
    entry.app.run(host='0.0.0.0', port=8080)

if __name__ == "__main__":
    entry_point()

Thanks

[20231023 - Update] I observed that 'Run time of job XXX was missed by 0:00:03.054418' on my app. It seems apscheduler has a mechanism that ignore cron job when missing my configured time.

I'll add misfire_grace_time, coalesce, and max_instances to test again.


Solution

  • I think the library does not do the action because of it miss the setting time. To avoid this, setting misfire_grace_time to allow the missing time region.