File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 1- __version__ = "2.14.4 "
1+ __version__ = "2.15.0 "
22__package_name__ = "scaleapi"
Original file line number Diff line number Diff line change @@ -151,16 +151,22 @@ def _api_request(
151151 # error=None,
152152 # status=409,
153153 # redirect_location=None)
154- if retry_history != ():
155- # See if the first retry was a 500 or 503 error
156- if retry_history [0 ][3 ] >= 500 :
157- uuid = body ["unique_id" ]
158- newUrl = f"{ self .base_api_url } /tasks?unique_id={ uuid } "
159- # grab task from api
160- newRes = self ._http_request (
161- "GET" , newUrl , headers = headers , auth = auth
162- )
163- json = newRes .json ()["docs" ][0 ]
154+
155+ if retry_history and retry_history [0 ][3 ] >= 500 :
156+ uuid = body ["unique_id" ]
157+ new_url = f"{ self .base_api_url } /tasks?unique_id={ uuid } "
158+
159+ # Perform a GET request to retrieve task data
160+ new_res = self ._http_request ("GET" , new_url , headers = headers , auth = auth )
161+
162+ if new_res .status_code == 200 :
163+ new_res_data = new_res .json ()
164+ if new_res_data ["docs" ]:
165+ json = new_res_data ["docs" ][0 ]
166+ else :
167+ self ._raise_on_respose (new_res )
168+ else :
169+ self ._raise_on_respose (new_res )
164170 else :
165171 self ._raise_on_respose (res )
166172 else :
You can’t perform that action at this time.
0 commit comments