Skip to content

Commit c4a1737

Browse files
committed
fix(client): adjust device activity polling to prevent rate limiting
Change polling interval from exponential backoff to linear and add initial delay. This prevents hitting rate limits while waiting for device activity completion.
1 parent 9e7e273 commit c4a1737

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pyaxm/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ def assign_unassign_device_to_mdm_server(
157157
)
158158

159159
# use the ID to check the status until it is complete
160+
# Waits before the first check to prevent rate limitting
161+
time.sleep(10)
160162
activity_response = self.abm.get_device_activity(unassign_response.data.id, self.access_token.value)
161163
retry = 0
162-
while 'COMPLETED' not in activity_response.data.attributes.status and retry < 5:
163-
time.sleep(2 ** retry)
164+
while activity_response.data.attributes.status == 'IN_PROGRESS' and retry < 5:
165+
time.sleep(10 * retry)
164166
retry += 1
165167
activity_response = self.abm.get_device_activity(unassign_response.data.id, self.access_token.value)
166168

0 commit comments

Comments
 (0)