Runs a task and re-schedule it
507444
def run(self, task):
        '''
        
        '''
        self._remove_dead_greenlet(task.name)
        if isinstance(task.timer, types.GeneratorType):
            # Starts the task immediately
            greenlet_ = gevent.spawn(task.action, *task.args, **task.kwargs)
            self.active[task.name].append(greenlet_)
            try:
                # total_seconds is available in Python 2.7
                greenlet_later = gevent.spawn_later(task.timer.next().total_seconds(), self.run, task)
                self.waiting[task.name].append(greenlet_later)
                return greenlet_, greenlet_later
            except StopIteration:
                pass
            return greenlet_, None
        # Class based timer
        try:
            if task.timer.started is False:
                delay = task.timer.next().total_seconds()
                gevent.sleep(delay)
                greenlet_ = gevent.spawn(task.action, *task.args, **task.kwargs)
                self.active[task.name].append(greenlet_)
            else:
                greenlet_ = gevent.spawn(task.action, *task.args, **task.kwargs)
                self.active[task.name].append(greenlet_)
            greenlet_later = gevent.spawn_later(task.timer.next().total_seconds(), self.run, task)
            self.waiting[task.name].append(greenlet_later)
            return greenlet_, greenlet_later
        except StopIteration:
            pass
        return greenlet_, None
1371297
public void schedule(BackoffTask task, long initialDelay, long fixedDelay) {
    	synchronized (queue) {
	    	start();
	        queue.put(new DelayedTimerTask(task, initialDelay, fixedDelay));
    	}
    }
863220
private void scheduleRenewalThresholdUpdateTask() {
        timer.schedule(new TimerTask() {
                           @Override
                           public void run() {
                               updateRenewalThreshold();
                           }
                       }, serverConfig.getRenewalThresholdUpdateIntervalMs(),
                serverConfig.getRenewalThresholdUpdateIntervalMs());
    }
1227515
async def run_task(self) -> None:
        ''''''

        while self.running:
            try:
                Log.debug('executing periodic task %s', self.name)
                before = self.time()
                await self.run()
                total = self.time() - before
                Log.debug('finished periodic task %s in %.1f seconds',
                          self.name, total)

                sleep = self.INTERVAL - total
                if sleep > 0:
                    await self.sleep(sleep)

            except CancelledError:
                Log.debug('cancelled periodic task %s', self.name)
                raise

            except Exception:
                Log.exception('exception in periodic task %s', self.name)
480113
def run(self, force=False):
        
        now = time.time()
        for func, spec in self.tasks.items():
            if force or now >= spec.get('next_run', 0):
                func()
                spec['next_run'] = now + spec['interval']
1144297
public synchronized void schedule()
    {
        // Avoid scheduling a timer that was destroyed on another thread and
        // avoid scheduling a timer twice, which might be attempted if two
        // threads concurrently attempt to cancel and then both rollback.
        if (ivTaskHandler == null && !ivDestroyed)
        {
            // Create the timer task handler (Runnable/Listener) and schedule the task
            ivTaskHandler = ivContainer.getEJBRuntime().createNonPersistentTimerTaskHandler(this);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "schedule: scheduling timer for " + ivExpiration + " / " + new Date(ivExpiration));

            ivTaskHandler.schedule(ivExpiration);
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "schedule: timer already scheduled or destroyed : destroyed=" + ivDestroyed);
        }
    }
1131847
public void run() {
		
		task.setSetTimerTransactionalAction(null);
		
		if (!canceled) {
			
			TimerTask previousTask = scheduler.getLocalRunningTasksMap().putIfAbsent(task.getData().getTaskID(), task);
			if(previousTask != null) {
				if (logger.isDebugEnabled()) {
					logger.debug("A task with id " + task.getData().getTaskID() + " has already been added to the local tasks, not rescheduling");
				}
			}
			
			final TimerTaskData taskData = task.getData();
			// calculate delay
			long delay = taskData.getStartTime() - System.currentTimeMillis();
			if (delay < 0) {
				delay = 0;
			}
			
			try {
				// schedule runnable
				if (taskData.getPeriod() < 0) {
					if (logger.isDebugEnabled()) {
						logger.debug("Scheduling one-shot timer with id "
								+ task.getData().getTaskID() + ", delay " + delay);
					}
					task.setScheduledFuture(scheduler.getExecutor().schedule(task, delay, TimeUnit.MILLISECONDS));
				} else {
					if (logger.isDebugEnabled()) {
						logger.debug("Scheduling periodic timer with id "
								+ task.getData().getTaskID() + ", scheduling strategy " + taskData.getPeriodicScheduleStrategy() + ", delay " + delay + ", period " + taskData.getPeriod());
					}
					if (taskData.getPeriodicScheduleStrategy() == PeriodicScheduleStrategy.withFixedDelay) {
						task.setScheduledFuture(scheduler.getExecutor().scheduleWithFixedDelay(task, delay, taskData.getPeriod(),TimeUnit.MILLISECONDS));
					}
					else {
						// default
						task.setScheduledFuture(scheduler.getExecutor().scheduleAtFixedRate(task, delay, taskData.getPeriod(),TimeUnit.MILLISECONDS));
					}					
				}		
			} catch (Throwable e) {
				logger.error(e.getMessage(), e);
				scheduler.remove(taskData.getTaskID(),true);
			}
		} else {
			if (logger.isDebugEnabled()) {
				logger.debug("Canceled scheduling periodic timer with id "
						+ task.getData().getTaskID());
			}
		}
	}
183663
def schedule_task(self):
        
        from .tasks import publish_task

        publish_task.apply_async(kwargs={'pk': self.pk}, eta=self.scheduled_time)
1175251
def run_once():
    
    if _debug: run_once._debug("run_once")
    global taskManager, deferredFns

    # reference the task manager (a singleton)
    taskManager = TaskManager()

    try:
        delta = 0.0
        while delta == 0.0:
            # get the next task
            task, delta = taskManager.get_next_task()
            if _debug: run_once._debug("    - task, delta: %r, %r", task, delta)

            # if there is a task to process, do it
            if task:
                taskManager.process_task(task)

            # check for deferred functions
            while deferredFns:
                # get a reference to the list
                fnlist = deferredFns
                deferredFns = []

                # call the functions
                for fn, args, kwargs in fnlist:
                    if _debug: run_once._debug("    - call: %r %r %r", fn, args, kwargs)
                    fn(*args, **kwargs)

                # done with this list
                del fnlist

    except KeyboardInterrupt:
        if _debug: run_once._info("keyboard interrupt")
    except Exception as err:
        if _debug: run_once._exception("an error has occurred: %s", err)
415865
private synchronized void start() {
        // only reschedule if monitor is still active (not in the process of being initialized or destroyed
        // don't schedule a task if there are no monitors or the monitorInterval was set to 0
        // don't schedule a task if the framework is stopping
        if (scheduledFuture == null
            && monitorState.get() == MonitorState.ACTIVE.ordinal()
            && !updateMonitors.isEmpty()
            && monitorInterval != 0
            && FrameworkState.isValid()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(this, tc, "Scan task scheduled");
            }
            scheduledFuture = coreService.getScheduler().scheduleWithFixedDelay(this, monitorInterval, monitorInterval, monitorTimeUnit);
        }
    }
170703
def run(self):
        """"""
        try:
            while not self.stopped:
                scraperobj = jobs.get(False)
                self.setName(scraperobj.getName())
                try:
                    self.getStrips(scraperobj)
                finally:
                    jobs.task_done()
                    self.setName(self.origname)
        except Empty:
            pass
        except KeyboardInterrupt:
            thread.interrupt_main()
118992
def run(task_creators, args, task_selectors=[]):
    
    if args.reset_dep:
        sys.exit(DoitMain(WrapitLoader(args, task_creators)).run(['reset-dep']))
    else:
        sys.exit(DoitMain(WrapitLoader(args, task_creators)).run(task_selectors))
1123603
def schedule_tasks(self):
        
        url = 'api/v6/releases/%d/schedule-tasks' % self.id
        tasks = yield self.connection._get(url)
        defer.returnValue(munchify(tasks))
890124
def RunOnce(self):
    """"""
    # Start the cron thread if configured to.
    if config.CONFIG["Cron.active"]:

      self.cron_worker = CronWorker()
      self.cron_worker.RunAsync()
695964
private void scheduleReload() {

        if (!isReloadScheduled() && (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT)) {
            // only schedule a reload if the system is not going down already
            m_threadCount++;
            Thread thread = new Thread("Bundle reload Thread " + m_threadCount) {

                @Override
                public void run() {

                    setReloadScheduled(true);
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                        // ignore
                    }
                    if (isReloadScheduled()) {
                        reload(false);
                    }
                    setReloadScheduled(false);
                }
            };
            thread.start();
        }
    }
850184
private void scheduleSendTask(boolean runNow) {
        TimerTask task = new TimerTask() {
            @Override
            public void run() {

                byte[] packet;

                try {
                    packet = packets.get(0);

                } catch (IndexOutOfBoundsException e) {
                    // No packets left; return without scheduling another run
                    return;

                }

                charc.setValue(packet);
                boolean result = gattClient.writeCharacteristic(charc);

                if (result) {
                    packets.remove(0);
                    int id = ids.remove(0);
                    retries = 0;

                    if (onPacketSent != null) {
                        onPacketSent.onResult(id);
                    }
                    Log.d(TAG, "Packet " + id + " sent after " + retries + " retries");

                } else {
                    retries++;

                }

                scheduleSendTask(false);
            }
        };

        if (runNow) {
            task.run();

        } else {
            sendTimer.schedule(task, SEND_INTERVAL);

        }
    }
1256739
private void swapAndCancelTask(AtomicReference<TimerTask> taskRef,
                                 TimerTask newTask) {
    TimerTask oldTask = taskRef.getAndSet(newTask);
    if (oldTask != null) {
      oldTask.cancel();
    }
  }