Skip to content

Commit

Permalink
Keep trying getting result even in case of HTTPError exception with s…
Browse files Browse the repository at this point in the history
…tatus 520 in the deprecated package (#54)
  • Loading branch information
cbjuan authored Aug 29, 2024
1 parent e4f1e26 commit e228cd4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qiskit_transpiler_service/wrappers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def get_supported_backends(self):
return resp

def request_status(self, endpoint, task_id):
def _giveup(e):
# Only retry 520 errors
return e.response.status_code != 520

@backoff.on_predicate(
backoff.constant,
lambda res: res.get("state") not in ["SUCCESS", "FAILURE"],
Expand All @@ -117,7 +121,9 @@ def request_status(self, endpoint, task_id):
requests.exceptions.Timeout,
requests.exceptions.ConnectionError,
requests.exceptions.JSONDecodeError,
requests.exceptions.HTTPError,
),
giveup=_giveup,
max_time=self.timeout,
)
def _request_status(self, endpoint, task_id):
Expand Down

0 comments on commit e228cd4

Please sign in to comment.