Пример #1
0
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
Пример #2
0
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
Пример #3
0
 def decorator(fn):
     return apply_async(celery_periodic_task(**kwargs)(fn), name=name)
Пример #4
0
 def decorator(fn):
     return apply_async(celery_periodic_task(**kwargs)(fn),
                        name=name)