Replies: 1 comment
-
Retrying code block from tenacity import Retrying, RetryError, stop_after_attempt
try:
for attempt in Retrying(stop=stop_after_attempt(3)):
with attempt:
raise Exception('My code is failing!')
except RetryError:
pass You can configure every details of retry policy by configuring the Retrying object. With async code you can use AsyncRetrying. from tenacity import AsyncRetrying, RetryError, stop_after_attempt
async def function():
try:
async for attempt in AsyncRetrying(stop=stop_after_attempt(3)):
with attempt:
raise Exception('My code is failing!')
except RetryError:
pass |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, we have a very inefficient way of handling retries. It's just a wild loop.
However, I strongly believe that we should utilize the tenacity library to improve this. One thing we could do in the future, once we've cleaned up the clients, is to support tenacity-like logic. It would be great if we could pass in:
or
Beta Was this translation helpful? Give feedback.
All reactions