-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeat API calls on timeouts #358
Conversation
try: | ||
proposals = await self._api.collect_offers(self._id, timeout=10, max_events=10) | ||
async with SuppressedExceptions(is_recoverable_exception): | ||
proposals = await self._api.collect_offers(self._id, timeout=5, max_events=10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping this call in SuppressedExceptions(is_recoverable_exception)
would ignore timeout errors and aiohttp.ServerDisconnectedError
.
Awesome fixes! 🥳 FYI the core team needs to double check if the re-tries are handled properly before releasing.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this PR very much. I would change the default interval to e.g. 0.5s (it's 0.0s currently) and max_tries to 3.
9825e90
to
fdca644
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@repeat_on_error(max_tries=5) | ||
async def details(self) -> AllocationDetails: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this method is never called, so there is no need to add @repeat_on_error
here.
I tested these changes with yagna daemon. Internal timeouts values were random, so that sometimes calls fail and sometimes succeed. |
Changes in this PR:
Executor
retry some operations that raise errors that indicate timeouts in API calls:Invoice.accept()
DebitNote.accept()
collect_offers()
get_invoice_events()
get_debit_note_events()
The "timeout errors" are HTTP errors 408 and 504,
asyncio.TimeoutError
(indicating client-side timeout) and intermittent errorsaiohttp.ClientDisconnectedError
andaiohttp.ClientOSError(errno=32)
(Broken Pipe).Should fix:
Note: "should fix" is obviously an overstatement, this PR won't prevent timeout-related API errors, it merely repeats each failed API call few times, making an assumption that the more attempts we make the less likely is that they will all fail.