fix: more robust retry mechanism on empty response

This commit is contained in:
Mike A.
2026-01-06 00:18:07 +01:00
parent b09db540ed
commit 4048438cfb

View File

@@ -652,6 +652,7 @@ class AsyncAppleAccount(BaseAppleAccount):
# Symptom: HTTP 200 but empty response
# Remove when real issue fixed
retry_counter = 1
_max_retries = 5
while True:
resp = await self._http.post(
self._ENDPOINT_REPORTS_FETCH,
@@ -663,13 +664,7 @@ class AsyncAppleAccount(BaseAppleAccount):
if resp.status_code != 200 or resp.text().strip():
return resp
logger.warning(
"Empty response received when fetching reports, retrying (%d/3)",
retry_counter,
)
retry_counter += 1
if retry_counter > 3:
if retry_counter > _max_retries:
logger.warning(
"Max retries reached, returning empty response. \
Location reports might be missing!"
@@ -679,7 +674,16 @@ class AsyncAppleAccount(BaseAppleAccount):
More info: https://github.com/malmeloo/FindMy.py/issues/185"
raise EmptyResponseError(msg)
await asyncio.sleep(2)
retry_time = 2 * retry_counter
logger.warning(
"Empty response received when fetching reports, retrying in %d seconds (%d/%d)",
retry_time,
retry_counter,
_max_retries,
)
await asyncio.sleep(retry_time)
retry_counter += 1
r = await _do_request()
if r.status_code == 401: