Exemple #1
0
 def wrapper(func):
     @wraps(func)
     def inner(*args, **kwargs):
         prev_language = translation.get_language()
         if prev_language != settings.LANGUAGE_CODE:
             translation.activate(settings.LANGUAGE_CODE)
         return func(*args, **kwargs)
     # prevent magic kwargs passthrough
     if not 'accept_magic_kwargs' in taskkwargs:
         taskkwargs['accept_magic_kwargs'] = False
     return celery_task(*taskargs, **taskkwargs)(inner)
Exemple #2
0
 def wrapper(func):
     @wraps(func)
     def inner(*args, **kwargs):
         prev_language = translation.get_language()
         if prev_language != settings.LANGUAGE_CODE:
             translation.activate(settings.LANGUAGE_CODE)
         return func(*args, **kwargs)
     # prevent magic kwargs passthrough
     if not 'accept_magic_kwargs' in taskkwargs:
         taskkwargs['accept_magic_kwargs'] = False
     return celery_task(*taskargs, **taskkwargs)(inner)
Exemple #3
0
def jtask(func, *args, **kwargs):
    """
    Java-exception aware task decorator for Celery.

    Re-throws the exception as a pickleable :class:`JavaException` object.
    """
    task = celery_task(func, *args, **kwargs)
    run = task.run

    @wraps(run)
    def call_task(*targs, **tkwargs):  # pylint: disable=C0111
        jvm_instance = jvm()

        try:
            return run(*targs, **tkwargs)
        except jvm_instance.JavaException, e:
            trace = sys.exc_info()[2]

            raise JavaException(e), None, trace