Skip to content

Commit 7fc823d

Browse files
Handle non-existing retries within Session object (#87)
1 parent aea93db commit 7fc823d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

scaleapi/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "2.15.6"
1+
__version__ = "2.15.7"
22
__package_name__ = "scaleapi"

scaleapi/api.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ def _api_request(
144144
# Some endpoints only return 'OK' message without JSON
145145
return json
146146
elif res.status_code == 409 and "task" in endpoint and body.get("unique_id"):
147-
retry_history = res.raw.retries.history
147+
retry_history = None
148+
if "retries" in res.raw and "history" in res.raw.retries:
149+
retry_history = res.raw.retries.history
150+
148151
# Example RequestHistory tuple
149152
# RequestHistory(method='POST',
150153
# url='/v1/task/imageannotation',
@@ -184,9 +187,9 @@ def post_request(self, endpoint, body=None, files=None, data=None):
184187
return self._api_request(
185188
"POST",
186189
endpoint,
187-
headers=self._headers
188-
if files is None
189-
else self._headers_multipart_form_data,
190+
headers=(
191+
self._headers if files is None else self._headers_multipart_form_data
192+
),
190193
auth=self._auth,
191194
body=body,
192195
files=files,

0 commit comments

Comments
 (0)