示例#1
0
 def _run_job(self, job: Job) -> None:
     try:
         super()._run_job(job)
     except Exception:
         if self.logger:
             self.logger.error(format_exc())
         job.last_run = datetime.now()
         job._schedule_next_run()
示例#2
0
    def register_cron_listener(self, cron_key: str, job: schedule.Job, listener):
        if job and listener:
            instance = self

            def job_closure():
                action = Action.create_cron_action(cron_key)
                action.listener = listener
                instance._action_queue.put(action)  # no protected access, just a closure

            job.do(job_closure)
示例#3
0
 def _run_job(self, job: Job):
     try:
         super()._run_job(job)
     except Exception:
         self.logger.error(
             f"Error while {next(iter(job.tags))}...\n{format_exc()}")
         job.last_run = datetime.datetime.now()
         if not self.rerun_immediately:
             # Reschedule the job for the next time it was meant to run, instead of letting it run
             # next tick
             job._schedule_next_run()
示例#4
0
文件: scheduler.py 项目: ivan1911/btb
 def _run_job(self, job: Job):
     try:
         super()._run_job(job)
     except Exception:  # pylint: disable=broad-except
         self.logger.error(
             f"Error while {next(iter(job.tags))}...\n{format_exc()}",
             notification=False)
         job.last_run = datetime.datetime.now()
         if not self.rerun_immediately:
             # Reschedule the job for the next time it was meant to run, instead of
             # letting it run
             # next tick
             job._schedule_next_run()  # pylint: disable=protected-access
示例#5
0
文件: at.py 项目: ecks0/lura
    def schedule(
        self,
        job: pyschedule.Job,
        target: Callable,
        args: Sequence[Any] = (),
        kwargs: Mapping[str, Any] = {},
        reenter: bool = True,
    ) -> None:
        'Schedule a task.'

        log = logger[self.log_level]  # type: ignore
        task = Task(target=target, args=args, kwargs=kwargs, reenter=reenter)
        log(f'Scheduling {self._format_task(job, task)}')
        job.do(task.run)
示例#6
0
def format_package(pack):
    sub, user, granule = pack

    return Job(
        hyp3_models.Subscription(**sub),
        hyp3_models.User(**user),
        hyp3_events.NewGranuleEvent(**granule)
    )
示例#7
0
 def _schmain(self) -> None:
     for method in self._onschmethods:
         meth_delta: Union[float, int] = method.__schinterval__.get(
             'delta', 0)
         if meth_delta > 0:
             Job(interval=meth_delta,
                 scheduler=self._schback).seconds.do(method).tag(
                     method.__name__)
         else:
             pass
     while True:
         with self._schlock:
             self._schback.run_pending()
         sleep(0.5)
示例#8
0
 def __schedule_job(self):
     self.__scheduler.clear()
     if in_production():
         for day in self.__days:
             job = Job(1, self.__scheduler)
             job.start_day = day.name.lower()
             job.unit = 'weeks'
             job.at(self.__start_time.strftime("%H:%M")).do(
                 self.__run_cycle)
     else:
         self.__scheduler.every(3).minutes.do(self.__run_cycle)
     logging.info('Next run scheduled for {0}.'.format(
         self.__scheduler.next_run))