Checklist
Related Issues and Possible Duplicates
Related Issues
Possible Duplicates
Description
In Calling Tasks:
You can also inspect the exception and traceback if the task raised an exception, in fact result.get() will propagate any errors by default:
>>> res = add.delay(2)
>>> res.get(timeout=1)
This example is not working as described because add.delay(2) results in the following error before the user is able to call res.get(timeout=1):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/app/task.py", line 425, in delay
return self.apply_async(args, kwargs)
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/app/task.py", line 530, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
TypeError: add() missing 1 required positional argument: 'y'
I suppose check_arguments() is a new function?
Suggestions
Change the example from:
>>> res = add.delay(2)
>>> res.get(timeout=1)
To an integer and string addition:
>>> res = add.delay(2, '2')
>>> res.get(timeout=1)
This way res = add.delay(2, '2') won't raise TypeError: add() missing 1 required positional argument: 'y'. And res.get(timeout=1) will propagate the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/result.py", line 221, in get
return self.backend.wait_for_pending(
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/backends/asynchronous.py", line 195, in wait_for_pending
return result.maybe_throw(callback=callback, propagate=propagate)
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/result.py", line 333, in maybe_throw
self.throw(value, self._to_remote_traceback(tb))
File "/home/abd/python/celery/env/lib/python3.8/site-packages/celery/result.py", line 326, in throw
self.on_ready.throw(*args, **kwargs)
File "/home/abd/python/celery/env/lib/python3.8/site-packages/vine/promises.py", line 244, in throw
reraise(type(exc), exc, tb)
File "/home/abd/python/celery/env/lib/python3.8/site-packages/vine/five.py", line 195, in reraise
raise value
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Checklist
for similar or identical bug reports.
for existing proposed fixes.
to find out if the bug was already fixed in the master branch.
(If there are none, check this box anyway).
Related Issues and Possible Duplicates
Related Issues
Possible Duplicates
Description
In Calling Tasks:
This example is not working as described because
add.delay(2)results in the following error before the user is able to callres.get(timeout=1):I suppose
check_arguments()is a new function?Suggestions
Change the example from:
To an integer and string addition:
This way
res = add.delay(2, '2')won't raiseTypeError: add() missing 1 required positional argument: 'y'. Andres.get(timeout=1)will propagate the following exception: