Skip to content

Commit

Permalink
fix the PollingBatch with the current version of yagna (#302)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
shadeofblue and filipgolem authored Apr 7, 2021
1 parent 157e69e commit 0cc5b18
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions yapapi/rest/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,13 @@ 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=min(timeout, 5)
)
except asyncio.TimeoutError:
continue
except ApiException as err:
if err.status == 408:
raise BatchTimeoutError()
continue
raise
any_new: bool = False
results = results[last_idx:]
Expand All @@ -194,7 +196,7 @@ async def __aiter__(self) -> AsyncIterator[events.CommandEventContext]:
if result.is_batch_finished:
break
if not any_new:
delay = min(10, max(0, self.seconds_left()))
delay = min(3, max(0, self.seconds_left()))
await asyncio.sleep(delay)


Expand Down

0 comments on commit 0cc5b18

Please sign in to comment.