Skip to content

Commit

Permalink
Merge pull request #315 from golemfactory/0.5/fix-polling-batch
Browse files Browse the repository at this point in the history
fix the PollingBatch with the current version of yagna (based on #302)
  • Loading branch information
shadeofblue authored Apr 7, 2021
2 parents ceba412 + 665b0bd commit 233b783
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 233b783

Please sign in to comment.