Add support for an async defined retry and callback_error_retry#289
Add support for an async defined retry and callback_error_retry#289symphony-youness wants to merge 4 commits intojd:mainfrom
Conversation
|
|
|
Hi @jd , |
Indeed, pep-8 error seems not to be related to this PR |
| prelude: > | ||
| Example use cases: | ||
| - if we get logged out from the server | ||
| - if authentication tokens expire | ||
| We want to be able to automatically refresh our session by calling a specific | ||
| function. This function can be asynchronously defined. | ||
| features: | ||
| - | | ||
| Asynchronous defined retry callbacks: | ||
| - retry | ||
| - retry_error_callback | ||
| issues: | ||
| - | | ||
| #249 | ||
|
|
There was a problem hiding this comment.
| prelude: > | |
| Example use cases: | |
| - if we get logged out from the server | |
| - if authentication tokens expire | |
| We want to be able to automatically refresh our session by calling a specific | |
| function. This function can be asynchronously defined. | |
| features: | |
| - | | |
| Asynchronous defined retry callbacks: | |
| - retry | |
| - retry_error_callback | |
| issues: | |
| - | | |
| #249 | |
| features: | |
| - Allow to define asynchronous defined retry callbacks by using `retry` or `retry_error_callback` |
|
|
||
| def wraps(self, fn): | ||
| fn = super().wraps(fn) | ||
|
|
| super(AsyncRetrying, self).__init__(**kwargs) | ||
| self.sleep = sleep | ||
|
|
||
| async def iter(self, retry_state): # noqa |
There was a problem hiding this comment.
why the noqa here? 🤔
I'm ok on the idea, but the implementation has too much copy pasting from the parent iter. It needs better refactoring for applying DRY.
| fut = retry_state.outcome | ||
| if fut is None: | ||
| if self.before is not None: | ||
| self.before(retry_state) |
There was a problem hiding this comment.
Can you also add async support for before and after callbacks?
|
@jd @fadedDexofan it has been almost a year since the last update on this PR, is there any developments? Do you guys need a help? Edit: Created a PR #363 to allow async callback for all parameters. |
|
I am picking back the work on this one, If you want to sync on it, I am down @mastizada |
|
@el-youness sure, happy to work on this. I made changes to support async functions for almost all functions, however, no update in the PR review for some time now :( |
|
hmmm, I will base myself on your PR, I think he said to DRY the iter method, I'll give it a go |
This issue raises the need for an asynchronously defined error callback: #249
This is a first approach to be able to use an asynchronously defined retry (on every retry iteration) and callback_error_retry (after the retrying is stopped)