Skip to content

Commit 327854c

Browse files
committed
Add add'l doc on RetryTask
[skip ci]
1 parent 3941012 commit 327854c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

docs/api.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,17 @@ Exceptions
14621462
task will be overridden and the value specified will be used to determine
14631463
when the task will be retried next.
14641464

1465+
.. code-block:: python
1466+
1467+
@huey.task()
1468+
def fetch_api_data(url):
1469+
try:
1470+
fh = urlopen(url)
1471+
except HTTPError:
1472+
# Try again in 60 seconds for an HTTP error (500, etc).
1473+
raise RetryTask(delay=60)
1474+
...
1475+
14651476
.. py:class:: TaskException
14661477
14671478
General exception raised by :py:class:`Result` handles when reading the

docs/guide.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,24 @@ It is also possible to explicitly retry a task from within the task, by raising
225225
a :py:class:`RetryTask` exception. When this exception is used, the task will
226226
be retried regardless of whether it was declared with ``retries``. Similarly,
227227
the task's remaining retries (if they were declared) will not be affected by
228-
raising :py:class:`RetryTask`.
228+
raising :py:class:`RetryTask`. Example:
229+
230+
.. code-block:: python
231+
232+
@huey.task()
233+
def fetch_api_data(url):
234+
try:
235+
fh = urlopen(url)
236+
except HTTPError:
237+
# Try again in 60 seconds for an HTTP error (500, etc).
238+
raise RetryTask(delay=60)
239+
...
229240
230241
For more information, see the following API documentation:
231242

232243
* :py:meth:`~Huey.task` and :py:meth:`~Huey.periodic_task`
233244
* :py:class:`Result`
245+
* :py:class:`RetryTask`
234246

235247
.. _priority:
236248

0 commit comments

Comments
 (0)