Schedule job to run at when nanoseconds since the UNIX epoch.
489674
def schedule(self, job, when):
        
        pjob = pickle.dumps(job)
        self._redis.zadd('ss:scheduled', when, pjob)
656244
private static Timestamp ofEpochSecond(long epochSecond, long nanoAdjustment) {
    long secs = TimeUtils.checkedAdd(epochSecond, floorDiv(nanoAdjustment, NANOS_PER_SECOND));
    int nos = (int) floorMod(nanoAdjustment, NANOS_PER_SECOND);
    return create(secs, nos);
  }
310730
def run(self, *args, **kwargs):
    """"""

    for job in self.jobs:
      job.run(*args, **kwargs)
418371
def at(time, callable=nil, opts={}, &block)

      do_schedule(:once, time, callable, opts, opts[:job], block)
    end
664333
def schedule(self, scheduled_time, func, args=None, kwargs=None,
                 interval=None, repeat=None, result_ttl=None, ttl=None,
                 timeout=None, id=None, description=None, queue_name=None,
                 meta=None):
        
        # Set result_ttl to -1 for periodic jobs, if result_ttl not specified
        if interval is not None and result_ttl is None:
            result_ttl = -1
        job = self._create_job(func, args=args, kwargs=kwargs, commit=False,
                               result_ttl=result_ttl, ttl=ttl, id=id,
                               description=description, queue_name=queue_name,
                               timeout=timeout, meta=meta)

        if interval is not None:
            job.meta['interval'] = int(interval)
        if repeat is not None:
            job.meta['repeat'] = int(repeat)
        if repeat and interval is None:
            raise ValueError("Can't repeat a job without interval argument")
        job.save()
        self.connection.zadd(self.scheduled_jobs_key,
                              {job.id: to_unix(scheduled_time)})
        return job
1160354
void reschedule(long delay, TimeUnit timeUnit) {
    long delayNanos = timeUnit.toNanos(delay);
    long newRunAtNanos = nanoTime() + delayNanos;
    enabled = true;
    if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) {
      if (wakeUp != null) {
        wakeUp.cancel(false);
      }
      wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS);
    }
    runAtNanos = newRunAtNanos;
  }
533915
def _schedule_processing_blocks(self):
        """"""
        LOG.info('Starting to Schedule Processing Blocks.')
        while True:
            time.sleep(0.5)
            if not self._queue:
                continue
            if self._num_pbcs >= self._max_pbcs:
                LOG.warning('Resource limit reached!')
                continue
            _inspect = Inspect(app=APP)
            if self._queue and _inspect.active() is not None:
                next_pb = self._queue[-1]
                LOG.info('Considering %s for execution...', next_pb[2])
                utc_now = datetime.datetime.utcnow()
                time_in_queue = (utc_now -
                                 datetime_from_isoformat(next_pb[4]))
                if time_in_queue.total_seconds() >= 10:
                    item = self._queue.get()
                    LOG.info('------------------------------------')
                    LOG.info('>>> Executing %s! <<<', item)
                    LOG.info('------------------------------------')
                    execute_processing_block.delay(item)
                    self._num_pbcs += 1
                else:
                    LOG.info('Waiting for resources for %s', next_pb[2])
166480
def run(self):
        
        while not self.stopped:
            now = datetime.utcnow()
            for job in self.parent.jobs:
                if not job.next_run:
                    continue
                if job.next_run >= self.last_check and job.next_run <= now:
                    if job.state.allow_start:
                        job.start()
                    else:
                        job.next_run = job.cron_iter.get_next(datetime)
            self.last_checked = now
            time.sleep(1)
998030
def scheduled():
    '''
    
    '''
    for job in sorted(schedulables(), key=lambda s: s.name):
        for task in PeriodicTask.objects(task=job.name):
            label = job_label(task.task, task.args, task.kwargs)
            echo(SCHEDULE_LINE.format(
                name=white(task.name.encode('utf8')),
                label=label,
                schedule=task.schedule_display
            ).encode('utf8'))
962898
function(crontab) {
    let _config = this[$EXTRA];
    
    _config.logger.info(`Setting up cron schedule ${crontab}`);

    _config.job = new CronJob({
      cronTime: crontab,
      onTick: _.bind(co.wrap(this._cronCallback), this),
      start: true,
    });

    /* calculate and save time between runs */
    
    // we add 1 second to next date otherwise, _getNextDateFrom() returns 
    // the same date back
    let nextRunDate = _config.job.nextDate().add(1, 'seconds');

    _config.timeBetweenRunsMs = 
      _config.job.cronTime._getNextDateFrom(nextRunDate).valueOf() - nextRunDate.valueOf();
  }
427130
def scheduled(wait=False):
    """"""
    manager.run_scheduled()
    while wait:
        # Loop and try to run scheduled crawlers at short intervals
        manager.run_scheduled()
        time.sleep(settings.SCHEDULER_INTERVAL)
487132
def timing(name=''):
  """"""
  start = datetime.datetime.now()
  timestamp = start.strftime('%H:%M')
  tf.logging.info('Starting job [%s] at %s', name, timestamp)
  yield
  end = datetime.datetime.now()
  timestamp = end.strftime('%H:%M')
  tf.logging.info('Finished job [%s] at %s', name, timestamp)
  duration = end - start
  duration_mins = duration.total_seconds() / 60
  tf.logging.info('Total time [%s] (m): %d', name, int(duration_mins))
1041760
def WriteCronJobRun(self, run_object, cursor=None):
    """"""
    query = ("INSERT INTO cron_job_runs "
             "(job_id, run_id, write_time, run) "
             "VALUES (%s, %s, FROM_UNIXTIME(%s), %s) "
             "ON DUPLICATE KEY UPDATE "
             "run=VALUES(run), write_time=VALUES(write_time)")

    write_time_str = mysql_utils.RDFDatetimeToTimestamp(
        rdfvalue.RDFDatetime.Now())
    try:
      cursor.execute(query, [
          run_object.cron_job_id,
          db_utils.CronJobRunIDToInt(run_object.run_id),
          write_time_str,
          run_object.SerializeToString(),
      ])
    except MySQLdb.IntegrityError as e:
      raise db.UnknownCronJobError(
          "CronJob with id %s not found." % run_object.cron_job_id, cause=e)
1251200
def run(self):
        """"""
        while not self._finished.isSet():
            self._func(self._reference)
            self._finished.wait(self._func._interval / 1000.0)
664702
def run_jobs(delete_completed=False, ignore_errors=False, now=None):
    
    if ScheduledJob.objects.filter(status='running'):
        raise ValueError('jobs in progress found; aborting')
    if now is None:
        now = datetime.datetime.now()

    expire_jobs(now)
    schedule_sticky_jobs()
    start_scheduled_jobs(now, delete_completed, ignore_errors)
155227
function runNow() {
              cancelTimer = null;
              start = null;
              runScheduledForNextTick = false;
              fn.apply(ctx, args);
            }
885211
def _create_scheduler(self, save_sensors):
        """"""
        @asyncio.coroutine
        def schedule_save():
            """Save sensors and schedule a new save."""
            yield from self.loop.run_in_executor(None, save_sensors)
            callback = partial(self.loop.create_task, schedule_save())
            task = self.loop.call_later(10.0, callback)
            self._cancel_save = task.cancel
        return schedule_save