Skip to content

Commit fdc77ff

Browse files
authored
Fix error propagation example (celery#5966)
1 parent f2ddd89 commit fdc77ff

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

docs/getting-started/next-steps.rst

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,33 @@ exception, in fact ``result.get()`` will propagate any errors by default:
328328

329329
.. code-block:: pycon
330330
331-
>>> res = add.delay(2)
331+
>>> res = add.delay(2, '2')
332332
>>> res.get(timeout=1)
333333
334334
.. code-block:: pytb
335335
336336
Traceback (most recent call last):
337-
File "<stdin>", line 1, in <module>
338-
File "/opt/devel/celery/celery/result.py", line 113, in get
339-
interval=interval)
340-
File "/opt/devel/celery/celery/backends/rpc.py", line 138, in wait_for
341-
raise meta['result']
342-
TypeError: add() takes exactly 2 arguments (1 given)
343-
344-
If you don't wish for the errors to propagate then you can disable that
345-
by passing the ``propagate`` argument:
337+
File "<stdin>", line 1, in <module>
338+
File "celery/result.py", line 221, in get
339+
return self.backend.wait_for_pending(
340+
File "celery/backends/asynchronous.py", line 195, in wait_for_pending
341+
return result.maybe_throw(callback=callback, propagate=propagate)
342+
File "celery/result.py", line 333, in maybe_throw
343+
self.throw(value, self._to_remote_traceback(tb))
344+
File "celery/result.py", line 326, in throw
345+
self.on_ready.throw(*args, **kwargs)
346+
File "vine/promises.py", line 244, in throw
347+
reraise(type(exc), exc, tb)
348+
File "vine/five.py", line 195, in reraise
349+
raise value
350+
TypeError: unsupported operand type(s) for +: 'int' and 'str'
351+
352+
If you don't wish for the errors to propagate then you can disable that by passing the ``propagate`` argument:
346353

347354
.. code-block:: pycon
348355
349356
>>> res.get(propagate=False)
350-
TypeError('add() takes exactly 2 arguments (1 given)',)
357+
TypeError("unsupported operand type(s) for +: 'int' and 'str'")
351358
352359
In this case it'll return the exception instance raised instead,
353360
and so to check whether the task succeeded or failed you'll have to

0 commit comments

Comments
 (0)