def __init__(self): if not hasattr(self, 'run_every'): raise NotImplementedError( 'Periodic tasks must have a run_every attribute') from celery.schedules import maybe_schedule self.run_every = maybe_schedule(self.run_every, self.relative) super(ShPeriodicTask, self).__init__()
def to_model_schedule(cls, schedule): for schedule_type, model_type, model_field in cls.model_schedules: schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(dbsession, schedule) return model_schedule, model_field raise ValueError( 'Cannot convert schedule type {0!r} to model'.format(schedule))
def to_model_schedule(cls, schedule): for schedule_type, model_type, model_field in cls.model_schedules: schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(db.session, schedule) return model_schedule, model_field raise ValueError( 'Cannot convert schedule type {0!r} to model'.format(schedule))
def to_model_schedule(cls, schedule): for schedule_type, model_type, model_field in cls.model_schedules: schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(schedule) model_schedule.save() return model_schedule, model_field raise ValueError('Cannot convert schedule type %r to model' % schedule)
def to_model_schedule(cls, schedule): for schedule_type, model_type, model_field in cls.model_schedules: schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(schedule) model_schedule.save() return model_schedule, model_field raise ValueError("Can't convert schedule type %r to model" % schedule)
def __init__(self): if not hasattr(self, 'run_every'): raise NotImplementedError( 'Periodic tasks must have a run_every attribute' ) from celery.schedules import maybe_schedule self.run_every = maybe_schedule(self.run_every, self.relative) super(ShPeriodicTask, self).__init__()
def __init__(self, name, last_run_at=None, total_run_count=None, schedule=None, args=(), kwargs={}, options={}, relative=False): self.name = name self.schedule = maybe_schedule(schedule, relative) self.args = args self.kwargs = kwargs self.options = options self.last_run_at = last_run_at or datetime.now() self.total_run_count = total_run_count or 0
def __init__(self, name=None, task=None, last_run_at=None, total_run_count=None, schedule=None, args=(), kwargs={}, options={}, relative=False): self.name = name self.task = task self.schedule = maybe_schedule(schedule, relative) self.args = args self.kwargs = kwargs self.options = options self.last_run_at = last_run_at or self._default_now() self.total_run_count = total_run_count or 0
def to_model_schedule(cls, schedule, session): """ :param session: :param schedule: :return: """ for schedule_type, model_type, model_field in cls.model_schedules: debug(cls.model_schedules) schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(session, schedule) cls.save_model(session, model_schedule) return model_schedule, model_field raise ValueError('Cannot convert schedule type {0!r} to model'.format(schedule))
def __init__(self): app = current_app if not hasattr(self, "run_every"): raise NotImplementedError( "Periodic tasks must have a run_every attribute") self.run_every = maybe_schedule(self.run_every, self.relative) # For backward compatibility, add the periodic task to the # configuration schedule instead. app.conf.CELERYBEAT_SCHEDULE[self.name] = { "task": self.name, "schedule": self.run_every, "args": (), "kwargs": {}, "options": self.options or {}, "relative": self.relative, } super(PeriodicTask, self).__init__()
def __init__(self): if not hasattr(self, "run_every"): raise NotImplementedError( "Periodic tasks must have a run_every attribute") self.run_every = maybe_schedule(self.run_every, self.relative) # Periodic task classes is pending deprecation. warnings.warn(PendingDeprecationWarning(PERIODIC_DEPRECATION_TEXT)) # For backward compatibility, add the periodic task to the # configuration schedule instead. conf.CELERYBEAT_SCHEDULE[self.name] = { "task": self.name, "schedule": self.run_every, "args": (), "kwargs": {}, "options": {}, "relative": self.relative, } super(PeriodicTask, self).__init__()
def __init__(self): if not hasattr(self, "run_every"): raise NotImplementedError("Periodic tasks must have a run_every attribute") self.run_every = maybe_schedule(self.run_every, self.relative) super(PeriodicTask, self).__init__()
def __init__(self): if not hasattr(self, "run_every"): raise NotImplementedError( "Periodic tasks must have a run_every attribute") self.run_every = maybe_schedule(self.run_every, self.relative) super(PeriodicTask, self).__init__()
def __init__(self): if not hasattr(self, 'run_every'): raise NotImplementedError( 'Periodic tasks must have a run_every attribute') self.run_every = maybe_schedule(self.run_every, self.relative) super().__init__()