def periodic_task(fn=None, **kwargs): from . import settings # register task if fn is None: name = kwargs.get('name', None) if settings.TASKS_BACKEND in ('thread', 'process'): def decorator(fn): return apply_async(celery_periodic_task(**kwargs)(fn), name=name) return decorator else: return celery_periodic_task(**kwargs) fn = celery_periodic_task(fn) if settings.TASKS_BACKEND in ('thread', 'process'): name = kwargs.pop('name', None) fn = update_wrapper(apply_async(fn, name), fn) return fn
def decorator(fn): return apply_async(celery_periodic_task(**kwargs)(fn), name=name)