Esempio n. 1
0
def task(fn=None, **kwargs):
    # TODO override this if 'celerybeat' in sys.argv ?
    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_shared_task(**kwargs)(fn), name=name)
            return decorator
        else:
            return celery_shared_task(**kwargs)
    fn = celery_shared_task(fn)
    if settings.TASKS_BACKEND in ('thread', 'process'):
        fn = apply_async(fn)
    return fn
Esempio n. 2
0
def task(fn=None, **kwargs):
    # TODO override this if 'celerybeat' in sys.argv ?
    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_shared_task(**kwargs)(fn), name=name)

            return decorator
        else:
            return celery_shared_task(**kwargs)
    fn = celery_shared_task(fn)
    if settings.TASKS_BACKEND in ('thread', 'process'):
        fn = apply_async(fn)
    return fn
Esempio n. 3
0
 def decorator(fn):
     return apply_async(celery_shared_task(**kwargs)(fn), name=name)
Esempio n. 4
0
 def decorator(fn):
     return apply_async(celery_shared_task(**kwargs)(fn), name=name)