Skip to content

Commit

Permalink
Update base.py with fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KarthikSKumar98 authored Jul 18, 2023
1 parent d56177f commit c861d2d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pycentral/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,19 +537,19 @@ def command(self, apiMethod, apiPath, apiData={}, apiParams={},
self.handleTokenExpiry()
retry += 1

elif resp.status_code == 429 and resp.headers['X-RateLimit-Remaining-second'] == 0: #check value
elif resp.status_code == 429 and resp.headers['X-RateLimit-Remaining-second'] == '0':
time.sleep(2)
self.logger.info("Per-second rate limit reached. Adding 2 seconds interval and retrying.")
if retry == self.user_retries-1:
limit_reached = True
retry +=1

elif resp.status_code == 429 and resp.headers['X-RateLimit-Remaining-day'] == 0: #check value
limit_renewal = "" #check value
self.logger.info("Per-day rate limit of " +str(resp.headers['X-RateLimit-Limit-day'])
+ " is exhausted. Daily rate limit quota will reset at: "
+ str(limit_renewal))
elif resp.status_code == 429 and resp.headers['X-RateLimit-Remaining-day'] == '0':
self.logger.info("Per-day rate limit of " + str(resp.headers['X-RateLimit-Limit-day'])
+ " is exhausted. Please check Central UI to see when the daily rate limit quota will be reset.")
limit_reached = True
else:
break

result = {
"code": resp.status_code,
Expand Down

0 comments on commit c861d2d

Please sign in to comment.