You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the current PyiCloud library behavior is suitable for most use cases, it triggers multiple API requests when calling specific device information methods. This can be optimal to ensure you get the freshest data, but can lead to excessive API usage in certain scenarios, such as frequent polling or when all of the data you need is present in the initial response. Frequent API calls usually correspond to an impact on battery state as well.
Environment
pyiCloud release with the issue (pip show pyicloud): Version: 1.0.0
Last working pyiCloud release (if known): Version: 1.0.0
This is not an error, but an optimization suggestion. With debug enabled or network sniffing, you will see a 'userInfo' response to each refresh request. There may be more than you expect.
Additional information
In many cases the first call contains all of the data that is needed and the other calls are redundant. Here's an optional optimization that can significantly reduce API calls. You can monkey patch the AppleDevice Class:
frompyicloud.services.findmyiphoneimportAppleDevice# Simple patch to prevent refresh_client from doing anything in AppleDevice methodsdefdo_nothing(self, *args, **kwargs):
pass# Patch the methods in AppleDevice that call refresh_clientAppleDevice.status=do_nothing# AppleDevice Class has most of the refresh calls. Use this for any troublesome methods.
This patch:
Prevents refresh_client() from being called in the patched methods.
Reduces API calls by ~60% when fetching device data of more than one type.
The text was updated successfully, but these errors were encountered:
tainium
changed the title
Optional optimization to reduce API calls for polling scenarios
Optional optimization to reduce API calls for certain scenarios
Jul 7, 2024
The problem
While the current PyiCloud library behavior is suitable for most use cases, it triggers multiple API requests when calling specific device information methods. This can be optimal to ensure you get the freshest data, but can lead to excessive API usage in certain scenarios, such as frequent polling or when all of the data you need is present in the initial response. Frequent API calls usually correspond to an impact on battery state as well.
Environment
pip show pyicloud
): Version: 1.0.0python -V
): Python 3.10.12Traceback/Error logs
This is not an error, but an optimization suggestion. With debug enabled or network sniffing, you will see a 'userInfo' response to each refresh request. There may be more than you expect.
Additional information
In many cases the first call contains all of the data that is needed and the other calls are redundant. Here's an optional optimization that can significantly reduce API calls. You can monkey patch the AppleDevice Class:
This patch:
The text was updated successfully, but these errors were encountered: