Skip to content

Commit 34c4622

Browse files
mlubejMatic Lubej
and
Matic Lubej
authored
wait for status update on partial retries (#360)
Co-authored-by: Matic Lubej <[email protected]>
1 parent 6eb2969 commit 34c4622

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

eogrow/pipelines/download_batch.py

+12
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def run_procedure(self) -> tuple[list[str], list[str]]:
205205
break
206206
LOGGER.info("Retrying due to PARTIAL status.")
207207
self.batch_client.restart_job(batch_request)
208+
batch_request = self._wait_for_partial_status_update(batch_request)
208209
results = self._monitor_job(batch_request)
209210

210211
processed = self._get_tile_names_from_results(results, BatchTileStatus.PROCESSED)
@@ -214,6 +215,17 @@ def run_procedure(self) -> tuple[list[str], list[str]]:
214215
LOGGER.info(log_msg)
215216
return processed, failed
216217

218+
def _wait_for_partial_status_update(self, batch_request: BatchRequest) -> BatchRequest:
219+
"""Wait for the batch job to update the status to PARTIAL with an exponential backoff."""
220+
wait_time, max_wait_time = 1, 5 * 60
221+
while wait_time < max_wait_time:
222+
time.sleep(wait_time)
223+
wait_time *= 2
224+
if self.batch_client.get_request(batch_request).status != BatchRequestStatus.PARTIAL:
225+
break
226+
227+
return self.batch_client.get_request(batch_request)
228+
217229
def _create_or_collect_batch_request(self) -> BatchRequest:
218230
"""Either creates a new batch request or collects information about an existing one."""
219231
if not self.config.batch_id:

0 commit comments

Comments
 (0)