Skip to content

Commit

Permalink
Add RetryCallState to the API docs (#419)
Browse files Browse the repository at this point in the history
* Add `RetryCallState` to the API docs

User code can access the `RetryCallState` so its members should be
documented.

* :noindex: `tenacity.RetryCallState` in the README

* Move `RetryCallState` docs to the API docs where hopefully they render on RTD
  • Loading branch information
rouge8 committed Nov 14, 2023
1 parent 3100582 commit f3d1909
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 43 deletions.
3 changes: 3 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Retry Main API
.. autoclass:: tenacity.tornadoweb.TornadoRetrying
:members:

.. autoclass:: tenacity.RetryCallState
:members:

After Functions
---------------

Expand Down
50 changes: 7 additions & 43 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,43 +402,7 @@ without raising an exception (or you can re-raise or do anything really)
RetryCallState
~~~~~~~~~~~~~~

``retry_state`` argument is an object of `RetryCallState` class:

.. autoclass:: tenacity.RetryCallState

Constant attributes:

.. autoattribute:: start_time(float)
:annotation:

.. autoattribute:: retry_object(BaseRetrying)
:annotation:

.. autoattribute:: fn(callable)
:annotation:

.. autoattribute:: args(tuple)
:annotation:

.. autoattribute:: kwargs(dict)
:annotation:

Variable attributes:

.. autoattribute:: attempt_number(int)
:annotation:

.. autoattribute:: outcome(tenacity.Future or None)
:annotation:

.. autoattribute:: outcome_timestamp(float or None)
:annotation:

.. autoattribute:: idle_for(float)
:annotation:

.. autoattribute:: next_action(tenacity.RetryAction or None)
:annotation:
``retry_state`` argument is an object of :class:`~tenacity.RetryCallState` class.

Other Custom Callbacks
~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -447,33 +411,33 @@ It's also possible to define custom callbacks for other keyword arguments.

.. function:: my_stop(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: whether or not retrying should stop
:rtype: bool

.. function:: my_wait(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: number of seconds to wait before next retry
:rtype: float

.. function:: my_retry(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: whether or not retrying should continue
:rtype: bool

.. function:: my_before(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

.. function:: my_after(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

.. function:: my_before_sleep(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

Here's an example with a custom ``before_sleep`` function:

Expand Down

0 comments on commit f3d1909

Please sign in to comment.