-
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
fix the PollingBatch with the current version of yagna #302
Conversation
…mfactory/yapapi into blue/polling-batch-timeout-argument
There are 2 issues here:
|
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.
LGTM!
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've realised, thanks to @filipgolem, that with _request_timeout
set, get_exec_batch_result()
could raise asyncio.TimeoutError
, not ApiException
, and therefore we should also catch that exception.
@@ -167,7 +167,7 @@ async def __aiter__(self) -> AsyncIterator[events.CommandEventContext]: | |||
raise BatchTimeoutError() | |||
try: | |||
results: List[yaa.ExeScriptCommandResult] = await self._api.get_exec_batch_results( | |||
self._activity_id, self._batch_id, timeout=timeout | |||
self._activity_id, self._batch_id, _request_timeout=timeout | |||
) | |||
except ApiException as err: |
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.
In addition to ApiException
we should also catch asyncio.TimeoutError
here and raise BatchTimeoutError
instead.
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 would also shorten the amount of sleep when no new results are available, at the end of this method. It's now 10 seconds:
yapapi/yapapi/rest/activity.py
Lines 196 to 198 in 157e69e
if not any_new: | |
delay = min(10, max(0, self.seconds_left())) | |
await asyncio.sleep(delay) |
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.
Yes, it's three seconds in yajsapi
.
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.
In addition to
ApiException
we should also catchasyncio.TimeoutError
here and raiseBatchTimeoutError
instead.
To avoid (tcp) connection closed errors, I limited maximum timeout to 5 seconds and added continue
when timeouts happen.
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.
Works well, good job!
* fix the PollingBatch with the current version of yagna * use aiohttp's general `_request_timeout` * Set maximum client-side timeout to 5 seconds, continue on client-side and server-side timeouts. * Decrease timeout Co-authored-by: Filip <[email protected]>
fix the PollingBatch with the current version of yagna (based on #302)
* fix the PollingBatch with the current version of yagna * use aiohttp's general `_request_timeout` * Set maximum client-side timeout to 5 seconds, continue on client-side and server-side timeouts. * Decrease timeout Co-authored-by: Filip <[email protected]>
No description provided.