Skip to content

Commit

Permalink
Add an example of overriding async retries
Browse files Browse the repository at this point in the history
Add an example of how to specify a different number of tries for
`retry_async_transaction` to the documentation.
  • Loading branch information
rra committed Jul 18, 2024
1 parent e10df16 commit 3ed499f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/user-guide/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,15 @@ Here's a simplified example from the storage layer of a Safir application:
job.start_time = start
If this method races with other methods updating the same job, the custom isolation level will force this update to fail with an exception, and it will then be retried by the decorator.

By default, the method is attempted three times.
This can be changed with a parameter to the decorator, such as:

.. code-block:: python
:emphasize-lines: 2
class Storage:
@retry_async_transaction(max_tries=5)
async def mark_start(self, job_id: str, start: datetime) -> None:
async with self._session.begin():
...

0 comments on commit 3ed499f

Please sign in to comment.