Skip to content

Feature request: make family device polling delay and max retries configurable #205

@spotshare-nick

Description

@spotshare-nick

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions