Description
When with_family=True, _initialize_devices() polls refreshClient in a tight loop while family members' deviceFetchStatus is "LOADING". The delay between retries is hardcoded to 0.1s and the max retries to 5 (findmyiphone.py:121-124):
if needs_refresh:
time.sleep(0.1)
self._refresh_client(locate=locate)
retries += 1
if retries >= _MAX_REFRESH_RETRIES:
With 5 retries at 0.1s, the total window is only 0.5s. For accounts with several family members, this often hits max retries before all devices finish loading.
Suggestion
Expose these as constructor parameters on FindMyiPhoneServiceManager, similar to how refresh_interval is already configurable:
def __init__(
self,
service_root: str,
token_endpoint: str,
session: PyiCloudSession,
params: dict[str, Any],
with_family=False,
refresh_interval: float | None = None,
family_poll_delay: float = 0.5,
family_poll_max_retries: int = 5,
) -> None:
Then in _initialize_devices():
if needs_refresh:
time.sleep(self._family_poll_delay)
self._refresh_client(locate=locate)
retries += 1
if retries >= self._family_poll_max_retries:
This would also need to be plumbed through PyiCloudService so callers can set it, e.g.:
api = PyiCloudService(username, password, family_poll_delay=0.5)
A higher default (e.g. 0.5s) would give Apple's backend more time to finish loading family device data before the next poll, reducing the chance of hitting max retries before all devices are ready.
Description
When
with_family=True,_initialize_devices()pollsrefreshClientin a tight loop while family members'deviceFetchStatusis"LOADING". The delay between retries is hardcoded to0.1sand the max retries to5(findmyiphone.py:121-124):With 5 retries at 0.1s, the total window is only 0.5s. For accounts with several family members, this often hits max retries before all devices finish loading.
Suggestion
Expose these as constructor parameters on
FindMyiPhoneServiceManager, similar to howrefresh_intervalis already configurable:Then in
_initialize_devices():This would also need to be plumbed through
PyiCloudServiceso callers can set it, e.g.:A higher default (e.g.
0.5s) would give Apple's backend more time to finish loading family device data before the next poll, reducing the chance of hitting max retries before all devices are ready.