So, I have a job which runs every day at a fixed time but the first time, I would like it to be run 5 mins after application startup (this is to prevent some uWSGI issue with replicas that I'm seeing). This is what I have so far:
scheduler = BackgroundScheduler(timezone=app.container.config.get("app.timezone"))
job_id = random.randint(0, 999)
job_name = f"mys_fetch_background_job_{job_id}"
# schedule data fetch and run now
scheduler.add_job(
my_service.fetch_data,
CronTrigger.from_crontab(
app.container.config.get("app.my_service.data_reload_cron_utc"),
# this value is 0 13 * * *
"UTC",
),
next_run_time=datetime.time(), # this executes on application startup immediately
id=str(job_id),
name=job_name
)
scheduler.start()
I'm trying to figure out how to schedule the first run just 5 mins after application startup - i.e. how can I do : next_run_time = datetime.time() + 5 mins