Issues

Issue #16 resolved

Maximum run count usage example

Dariusz Suchojad
created an issue

Hello,

I'm in a process of migrating the code using APScheduler 1.x over to 2.x series and have noticed a changelog entry "Maximum run count can be configured for all jobs, not just those using interval-based scheduling" at http://packages.python.org/APScheduler/index.html#id3

The trouble is that I can't seem to find any usage example of the said feature. Comparing the code base 1.x vs. 2.x I can see the IntervalTrigger's init method no longer accepts the 'repeat' method yet there doesn't seem to be any equivalent way of achieving the same result.

Can you please shed some light on this and post a piece of sample code showing how one should use the feature in 2.x?

Thanks!

Comments (8)

  1. Dariusz Suchojad reporter

    OK, but the apscheduler.job.Job's docs say "Job instances are created by the scheduler when adding jobs, and it should not be directly instantiated." and I haven't ever had a need to use this class directly before.

    Could either the 'max_runs' parameter be added to Scheduler.add_interval_job and Scheduler.add_cron_job or the docstring updated so that users don't get an impression they shouldn't be tinkering with this class themselves?

    On a related note, how does 'max_runs' influence one-time jobs? I mean, how can a job be both of a one-time type and have 'max_runs' provided? I'm asking because the changelog says the parameter is to do with all the jobs, not only interval-based and cron-style ones.

  2. Alex Grönholm repo owner

    You misunderstand. Just pass max_runs=<whatever> to add_interval_job() or whatever. The job adding functions pass along all keyword arguments to Job.

  3. Log in to comment