Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks and errbacks do not work with CELERY_ALWAYS_EAGER #1336

Closed
charlax opened this issue May 1, 2013 · 3 comments
Closed

Callbacks and errbacks do not work with CELERY_ALWAYS_EAGER #1336

charlax opened this issue May 1, 2013 · 3 comments

Comments

@charlax
Copy link
Contributor

charlax commented May 1, 2013

Here's an example code:

from celery import Celery

celery = Celery('hello',
                backend='redis://localhost:6379/3',
                broker='redis://localhost:6379/3')

celery.conf.update(
    CELERY_ALWAYS_EAGER=True,
)


@celery.task
def hello():
    print "Here"
    return


@celery.task
def raise_exception():
    raise TypeError()


def main():
    r = raise_exception.apply_async(link_error=hello.s())
    # r.get()

if __name__ == '__main__':
    main()

One would expect that this code prints "Here", but it does not.

Will try to fix by myself, in the meantime would appreciate any help.

Thanks

@charlax
Copy link
Contributor Author

charlax commented May 1, 2013

Note that using CELERY_EAGER_PROPAGATES_EXCEPTIONS is even worse because it raises the exception directly:

Traceback (most recent call last):
  File "hello.py", line 29, in <module>
    main()
  File "hello.py", line 25, in main
    r = raise_exception.apply_async(link_error=hello.s())
  File "/Users/ca/.virtualenvs/celerydebug/lib/python2.7/site-packages/celery-3.1.0rc1-py2.7.egg/celery/app/task.py", line 458, in apply_async
    return self.apply(args, kwargs, task_id=task_id, **options)
  File "/Users/ca/.virtualenvs/celerydebug/lib/python2.7/site-packages/celery-3.1.0rc1-py2.7.egg/celery/app/task.py", line 633, in apply
    request=request, propagate=throw)
  File "/Users/ca/.virtualenvs/celerydebug/lib/python2.7/site-packages/celery-3.1.0rc1-py2.7.egg/celery/task/trace.py", line 292, in eager_trace_task
    uuid, args, kwargs, request)
  File "/Users/ca/.virtualenvs/celerydebug/lib/python2.7/site-packages/celery-3.1.0rc1-py2.7.egg/celery/task/trace.py", line 204, in trace_task
    R = retval = fun(*args, **kwargs)
  File "hello.py", line 21, in raise_exception
    raise TypeError()
TypeError

@ask
Copy link
Contributor

ask commented May 1, 2013

Maybe the better solution is to avoid calling the errback in this case.

Always eager will never be feature complete anyway, and it's better for tests to mock this.

@ask ask closed this as completed in 934d189 May 14, 2013
@charlax
Copy link
Contributor Author

charlax commented May 14, 2013

Awesome! Thanks @ask!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants