def make_periodic_task(self): """ Create a heartbeat @periodic_task specifically for self.queue This is called on python startup so should avoid network calls and anything else slow. """ def heartbeat(): try: self.get_and_report_blockage_duration() except HeartbeatNeverRecorded: pass self.mark_seen() heartbeat.__name__ = str(self.periodic_task_name) heartbeat = periodic_task(run_every=HEARTBEAT_FREQUENCY, queue=self.queue)(heartbeat) return heartbeat
def _compat_periodic_task_decorator(*args, **kwargs): from celery.task import periodic_task return periodic_task(*args, **kwargs)
def _compat_periodic_task_decorator(*args, **kwargs): from celery.task import periodic_task kwargs.setdefault('accept_magic_kwargs', True) return periodic_task(*args, **kwargs)
def periodic_task(*args, **kwargs): # ✞ kwargs.setdefault("accept_magic_kwargs", True) return _task.periodic_task(*args, **kwargs)
def periodic_task(*args, **kwargs): from celery.task import periodic_task kwargs.setdefault("accept_magic_kwargs", True) return periodic_task(*args, **kwargs)
""" If celery is installed, register our maintenance commands as periodic tasks to avoid the requirement for external crond. """ try: from datetime import timedelta from celery.task import periodic_task from ella.core.management import generate_publish_signals, regenerate_listing_handlers periodic_task(run_every=timedelta(minutes=5))(generate_publish_signals) periodic_task(run_every=timedelta(hours=3))(regenerate_listing_handlers) except ImportError: # celery not installed pass
""" If celery is installed, register our maintenance commands as periodic tasks to avoid the requirement for external crond. """ try: import celery except ImportError: # celery not installed pass else: from datetime import timedelta from celery.task import periodic_task from ella.core.management import generate_publish_signals, regenerate_listing_handlers periodic_task(run_every=timedelta(minutes=5))(generate_publish_signals) periodic_task(run_every=timedelta(hours=3))(regenerate_listing_handlers)
def periodic_task_on_envs(envs, *args, **kwargs): if settings.SERVER_ENVIRONMENT in envs: return periodic_task(*args, **kwargs) else: return lambda fn: fn