Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

next run time missed by some seconds in job scheduling in apscheuler

i have a function to execute cron job as

def add_config_job(sched, job):

    module = JOB_METHODS.get(job["type"])
    if module is None:
        logging.warn("job type %r not supported", job["type"])
        return

    func = module.cron_job
    args = (job,)
    name = "%s__%s" % (job["name"], job["id"])
    start_date = job.get("start_date")
    run_at = job["run_at"]

    if isinstance(job["run_at"], dict):
        sched.add_cron_job(func, args=args, name=name, start_date=start_date,
                           **run_at)
    elif isinstance(job["run_at"], basestring):
        sched.add_date_job(func, args=args, name=name, date=run_at)
    else:
        logging.warn("unsupported 'run_at' type (%s given)", run_at)

and I get the error as missed job by some seconds as

2015-05-14_00:00:02.76629 WARNING: Run time of job "Daily VPN Connexion__1 (trigger: cron[day='*', hour='0', minute='0', second='0'], next run at: 2015-05-14 00:00:00)" was missed by 0:00:02.493426
2015-05-14_00:00:02.79309 WARNING: Run time of job "Daily Report VPN Connection ALIGRO__1 (trigger: cron[day='*', hour='0', minute='0', second='0'], next run at: 2015-05-14 00:00:00)" was missed by 0:00:02.777450

what is the cause of this misfiring of the job? how can we avoid it? in some pages I found to increase the misfire_grace_time from the default of 1 second. shouldn't be the scheduler schedule in proper time without missing it?

like image 939
user3545251 Avatar asked May 14 '15 10:05

user3545251


People also ask

What is Max_instances in APScheduler?

The max_instances only tells you how many concurrent jobs you can have. APScheduler has three types of triggers: date interval cron. interval and cron repeat forever, date is a one-shot on a given date.

What is APScheduler in Python?

Schedule lets you run Python functions (or any other callable) periodically at pre-determined intervals using a simple, human-friendly syntax. Schedule Library is used to schedule a task at a particular time every day or a particular day of a week.


1 Answers

It seems to be that your process is too busy to start the jobs in a timely manner. The misfire_grace_time option is there to prevent jobs from firing after they're no longer relevant. If something needs to happen at some exact time and it's delayed too much, it shouldn't happen at all. Increasing misfire_grace_time is the solution if this is happening and you don't care about accuracy so much.

like image 72
Alex Grönholm Avatar answered Sep 24 '22 02:09

Alex Grönholm