forked from adafruit/adabot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rate limiting from pygithub.RateLimitExceededException (adafruit#263
) The "core rate limit reset" time is in UTC, while github actions may be running in another timezone, such as PST. The below example was run in my local timezone, CST: ```python >>> import os, datetime >>> import github as pygithub >>> GH_INTERFACE = pygithub.Github(os.environ.get("ADABOT_GITHUB_ACCESS_TOKEN")) >>> GH_INTERFACE.get_rate_limit().core.reset - datetime.datetime.now() datetime.timedelta(seconds=24750, microseconds=356986) >>> GH_INTERFACE.get_rate_limit().core.reset - datetime.datetime.utcnow() datetime.timedelta(seconds=3147, microseconds=87271) ``` Use utcnow() instead of now() so that the sleep is for the correct duration. (utcnow is deprecated, but the correct alternative, `now(tz=datetime.timezone.utc)` does not work: `GH_INTERFACE.get_rate_limit().core.reset` is a naive timestamp and can't be compared with a tz-aware object)
- Loading branch information
Showing
3 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters