This logic could be improved:


    while ($job = db_fetch_array($result)) {
      // Flag periodic jobs as scheduled, remove one-off jobs.
      if ($job['periodic']) {
        $job['scheduled'] = $job['last'] = JOB_SCHEDULER_REQUEST_TIME;
        $job['next'] = $job['period'] + JOB_SCHEDULER_REQUEST_TIME;
        drupal_write_record('job_schedule', $job, array('callback', 'type', 'id'));
      }
      else {
        $this->remove($job);
      }
      // Queue job if there is a queue declared for it, otherwise execute it.
      if (function_exists($job['callback'])) {
        if (!$this->queue($job)) {
          $job['callback']($job);
        }
      }

Why the record of non-periodic job is removed first, before job is executed?
What if callback execution is not finished, took too long, or something?
Logically for me should be execute the job, and after it's successful, remove it.

Comments

mstrelan’s picture

+1

twistor’s picture

Status: Active » Closed (works as designed)

If the job is unsuccessful, has a fatal error, takes too long, then it shouldn't run again.