Skip to content

Commit

Permalink
Merge pull request #90 from NERSC/result-fix
Browse files Browse the repository at this point in the history
Use status to determine exit condition
  • Loading branch information
cjh1 authored Sep 27, 2024
2 parents c0a24bc + 3bac936 commit 5c8bc9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/sfapi_client/_async/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ async def _wait_for_task(self, task_id) -> str:
json_response = r.json()
task = Task.model_validate(json_response)

if task.status.lower() in ["error", "failed"]:
status = task.status.lower()
if status in ["error", "failed"]:
raise SfApiError(task.result)

if task.result is None:
if status not in ["completed", "cancelled"]:
await _ASYNC_SLEEP(1)
continue

Expand Down
5 changes: 3 additions & 2 deletions src/sfapi_client/_sync/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ def _wait_for_task(self, task_id) -> str:
json_response = r.json()
task = Task.model_validate(json_response)

if task.status.lower() in ["error", "failed"]:
status = task.status.lower()
if status in ["error", "failed"]:
raise SfApiError(task.result)

if task.result is None:
if status not in ["completed", "cancelled"]:
_SLEEP(1)
continue

Expand Down

0 comments on commit 5c8bc9d

Please sign in to comment.