APScheduler `add_job()` `next_run_time` values

38 Views Asked by At

I'm enqueuing a couple of Jobs, using BackgroundScheduler and add_job, based on config values.

Primarily the jobs will run based on crontab string.

But they may also run once at program startup with a configured delay.

For the former I'm using trigger=CronTrigger.from_crontab(cron_tab).

For the latter, I want to use next_run_time, using .datetime.now() + timedelta(x)

When both configs are defined this all seems fine and happy. But I want to be able to set my config values to None to not do those things....


The docs for next_run_time say:

(pass None to add the job as paused)

What does that mean?

Does that just mean "there won't be a dedicated initial run ... it'll just wait for the next time the cron arrives"? Or does it mean "this will create a disabled job which will never run at all?"


And I can't find any docs about None in trigger or CronTrigger.from_crontab() can I pass None into either of those to cause the job to just run once (based on the next_run_time and then never again?

0

There are 0 best solutions below