Example #1
0
    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
Example #2
0
def _compat_periodic_task_decorator(*args, **kwargs):
    from celery.task import periodic_task
    return periodic_task(*args, **kwargs)
Example #3
0
def _compat_periodic_task_decorator(*args, **kwargs):
    from celery.task import periodic_task
    kwargs.setdefault('accept_magic_kwargs', True)
    return periodic_task(*args, **kwargs)
Example #4
0
def periodic_task(*args, **kwargs):  # ✞
    kwargs.setdefault("accept_magic_kwargs", True)
    return _task.periodic_task(*args, **kwargs)
Example #5
0
 def periodic_task(*args, **kwargs):
     from celery.task import periodic_task
     kwargs.setdefault("accept_magic_kwargs", True)
     return periodic_task(*args, **kwargs)
Example #6
0
File: tasks.py Project: 3108as/ella
"""
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

Example #7
0
"""
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)
Example #8
0
def _compat_periodic_task_decorator(*args, **kwargs):
    from celery.task import periodic_task
    return periodic_task(*args, **kwargs)
Example #9
0
def _compat_periodic_task_decorator(*args, **kwargs):
    from celery.task import periodic_task
    kwargs.setdefault('accept_magic_kwargs', True)
    return periodic_task(*args, **kwargs)
Example #10
0
def periodic_task_on_envs(envs, *args, **kwargs):
    if settings.SERVER_ENVIRONMENT in envs:
        return periodic_task(*args, **kwargs)
    else:
        return lambda fn: fn