Schedule a precompute task for `panel`
426698
def enable_precompute(panel):
  """"""
  use_metis = panel['data_source']['source_type'] == 'querybuilder'
  if use_metis:
    query = panel['data_source']['query']
  else:
    query = "u'''%s'''" % panel['data_source']['code']
  precompute = panel['data_source']['precompute']
  timeframe = panel['data_source']['timeframe']
  bucket_width = precompute['bucket_width']['value']
  time_scale = precompute['bucket_width']['scale']['name']
  bucket_width_seconds = get_seconds(bucket_width, time_scale)

  if timeframe['mode']['value'] == 'recent':
    untrusted_time = precompute['untrusted_time']['value']
    untrusted_time_scale = precompute['untrusted_time']['scale']['name']
    untrusted_time_seconds = get_seconds(untrusted_time, untrusted_time_scale)
    # Schedule the task with an interval equal to the bucket_width
    interval = bucket_width_seconds
  elif timeframe['mode']['value'] == 'range':
    untrusted_time_seconds = 0
    # Schedule the task with an interval of 0 so it only runs once
    interval = 0

  task_code = PRECOMPUTE_INITIALIZATION_CODE % (query, timeframe,
                                                bucket_width_seconds,
                                                untrusted_time_seconds,
                                                use_metis)
  result = scheduler_client.schedule(task_code, interval)

  if result['status'] != 'success':
    raise RuntimeError(result.get('reason'))

  return result['id']
563588
private void schedule(int offset) {
		if (isPending(offset)) {
			return;
		}
		
		int startOffset = Math.max(0, offset - maxPageSize / 2);
		int length = offset + maxPageSize / 2 - startOffset;
		
		load(startOffset, length);
	}
464838
private void scheduleUpdate() {
		if (!isVisible()) {
			return;
		}
		
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				try {
					container.gameLoop();
				} catch (SlickException e) {
					e.printStackTrace();
				}
				container.checkDimensions();
				scheduleUpdate();
			}
		});
	}
1199068
def _ScheduleTasks(self, storage_writer):
    
    logger.debug('Task scheduler started')

    self._status = definitions.STATUS_INDICATOR_RUNNING

    # TODO: make tasks persistent.

    # TODO: protect task scheduler loop by catch all and
    # handle abort path.

    event_source_heap = _EventSourceHeap()

    self._FillEventSourceHeap(
        storage_writer, event_source_heap, start_with_first=True)

    event_source = event_source_heap.PopEventSource()

    task = None
    while event_source or self._task_manager.HasPendingTasks():
      if self._abort:
        break

      try:
        if not task:
          task = self._task_manager.CreateRetryTask()

        if not task and event_source:
          task = self._task_manager.CreateTask(self._session_identifier)
          task.file_entry_type = event_source.file_entry_type
          task.path_spec = event_source.path_spec
          event_source = None

          self._number_of_consumed_sources += 1

          if self._guppy_memory_profiler:
            self._guppy_memory_profiler.Sample()

        if task:
          if self._ScheduleTask(task):
            logger.debug(
                'Scheduled task {0:s} for path specification {1:s}'.format(
                    task.identifier, task.path_spec.comparable))

            self._task_manager.SampleTaskStatus(task, 'scheduled')

            task = None

          else:
            self._task_manager.SampleTaskStatus(task, 'schedule_attempted')

        self._MergeTaskStorage(storage_writer)

        if not event_source_heap.IsFull():
          self._FillEventSourceHeap(storage_writer, event_source_heap)

        if not task and not event_source:
          event_source = event_source_heap.PopEventSource()

      except KeyboardInterrupt:
        self._abort = True

        self._processing_status.aborted = True
        if self._status_update_callback:
          self._status_update_callback(self._processing_status)

    for task in self._task_manager.GetFailedTasks():
      warning = warnings.ExtractionWarning(
          message='Worker failed to process path specification',
          path_spec=task.path_spec)
      self._storage_writer.AddWarning(warning)
      self._processing_status.error_path_specs.append(task.path_spec)

    self._status = definitions.STATUS_INDICATOR_IDLE

    if self._abort:
      logger.debug('Task scheduler aborted')
    else:
      logger.debug('Task scheduler stopped')
1148346
def process(self, sched, coro):
        """"""

        if self.prio == priority.DEFAULT:
            self.prio = sched.default_priority
69164
def _run(self):
        
        for node in self.node.relatives:
            launch_node_task(node)
        for node in self.node.relatives:
            self.wait_and_join(node.task)
        if self.node.parent:
            while not self.node.parent.task.siblings_permission:
                time.sleep(self._polling_time)
        self.has_started = True
        self.main()
        self.siblings_permission = True
        for node in self.node.siblings:
            launch_node_task(node)
        for node in self.node.siblings:
            self.wait_and_join(node.task)
        self.finished_at = time.time()
        self.scheduler.notify_execution(self)
        self.has_finished = True
418432
public void schedule(Runnable task, long delayInMillis) {
        if (isTerminatedOrSteppedDown()) {
            return;
        }

        raftIntegration.schedule(task, delayInMillis, MILLISECONDS);
    }
373979
function schedule(parent$, schedule, onDone = () => {}) {
  let iteration = 0;
  let newStream = fork$(parent$, value =>
    executeScheduleItem(schedule, iteration++, value)
  );
  if (schedule.length === iteration) onDone();

  parent$.listeners.push(function checkSchedule(value) {
    // do immediate to prevent schedule items to update parent streams before child streams ran
    setImmediate(async () => {
      newStream(await executeScheduleItem(schedule, iteration++, value));
      if (iteration === schedule.length) onDone();
    });
  });
  return newStream;
}
553527
def _pre_tasks(self):
        
        if self.flushdb:
            management.call_command('flush', verbosity=0, interactive=False)
            logger.info('Flushed database')
508641
def scheduled_event_trigger(self, event_type):
        """"""
        def callback(when, **kwargs):
            self.queued_scheduled_events.append((when, event_type(when=when, **kwargs)))
        return callback
368046
public static void scheduleWithFixedDelay(
      final ScheduledExecutorService exec,
      final Duration initialDelay,
      final Duration delay,
      final Callable<Signal> callable
  )
  {
    log.debug("Scheduling repeatedly: %s with delay %s", callable, delay);
    exec.schedule(
        new Runnable()
        {
          @Override
          public void run()
          {
            try {
              log.debug("Running %s (delay %s)", callable, delay);
              if (callable.call() == Signal.REPEAT) {
                log.debug("Rescheduling %s (delay %s)", callable, delay);
                exec.schedule(this, delay.getMillis(), TimeUnit.MILLISECONDS);
              } else {
                log.debug("Stopped rescheduling %s (delay %s)", callable, delay);
              }
            }
            catch (Throwable e) {
              log.error(e, "Uncaught exception.");
            }
          }
        },
        initialDelay.getMillis(),
        TimeUnit.MILLISECONDS
    );
  }
1362618
def scheduler(ctx, xmlrpc, xmlrpc_host, xmlrpc_port,
              inqueue_limit, delete_time, active_tasks, loop_limit, fail_pause_num,
              scheduler_cls, threads, get_object=False):
    
    g = ctx.obj
    Scheduler = load_cls(None, None, scheduler_cls)

    kwargs = dict(taskdb=g.taskdb, projectdb=g.projectdb, resultdb=g.resultdb,
                  newtask_queue=g.newtask_queue, status_queue=g.status_queue,
                  out_queue=g.scheduler2fetcher, data_path=g.get('data_path', 'data'))
    if threads:
        kwargs['threads'] = int(threads)

    scheduler = Scheduler(**kwargs)
    scheduler.INQUEUE_LIMIT = inqueue_limit
    scheduler.DELETE_TIME = delete_time
    scheduler.ACTIVE_TASKS = active_tasks
    scheduler.LOOP_LIMIT = loop_limit
    scheduler.FAIL_PAUSE_NUM = fail_pause_num

    g.instances.append(scheduler)
    if g.get('testing_mode') or get_object:
        return scheduler

    if xmlrpc:
        utils.run_in_thread(scheduler.xmlrpc_run, port=xmlrpc_port, bind=xmlrpc_host)
    scheduler.run()
216567
function scheduleTask(task) {
        frameTasks.push(task);
        if (rafId === -1) {
            requestAnimationFrame(function (t) {
                rafId = -1;
                var tasks = frameTasks;
                frameTasks = [];
                for (var i = 0; i < tasks.length; i++) {
                    tasks[i]();
                }
            });
        }
    }
1284717
public void scheduleTask(PyObject task, double delay) {
        mTimer.schedule(new PythonCallTimerTask(task), Math.round(delay * 1000));
    }
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)
365988
def schedule(self, task: Schedulable, *args, **kwargs):
        
        at = datetime.now(timezone.utc)
        self.schedule_at(task, at, *args, **kwargs)
1076284
def schedule(self, function, args=(), kwargs={}):
        
        self._check_pool_state()

        future = Future()
        payload = TaskPayload(function, args, kwargs)
        task = Task(next(self._task_counter), future, None, payload)

        self._context.task_queue.put(task)

        return future