Skip to content
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) #315

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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