Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support negative retries value
  • Loading branch information
kristjanvalur committed Apr 14, 2022
commit eb290e7c378d2d3dfda7b47b21fe16dbf73317b8
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Allow negative `retries` for `Retry` class to retry forever
* Add `items` parameter to `hset` signature
* Create codeql-analysis.yml (#1988). Thanks @chayim
* Add limited support for Lua scripting with RedisCluster
Expand Down
3 changes: 2 additions & 1 deletion redis/asyncio/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(
"""
Initialize a `Retry` object with a `Backoff` object
that retries a maximum of `retries` times.
`retries` can be negative to retry forever.
You can specify the types of supported errors which trigger
a retry with the `supported_errors` parameter.
"""
Expand All @@ -51,7 +52,7 @@ async def call_with_retry(
except self._supported_errors as error:
failures += 1
await fail(error)
if failures > self._retries:
if self._retries >= 0 and failures > self._retries:
raise error
backoff = self._backoff.compute(failures)
if backoff > 0:
Expand Down
3 changes: 2 additions & 1 deletion redis/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
"""
Initialize a `Retry` object with a `Backoff` object
that retries a maximum of `retries` times.
`retries` can be negative to retry forever.
You can specify the types of supported errors which trigger
a retry with the `supported_errors` parameter.
"""
Expand Down Expand Up @@ -46,7 +47,7 @@ def call_with_retry(self, do, fail):
except self._supported_errors as error:
failures += 1
fail(error)
if failures > self._retries:
if self._retries >= 0 and failures > self._retries:
raise error
backoff = self._backoff.compute(failures)
if backoff > 0:
Expand Down