Skip to content

Commit

Permalink
- Addressing review note.
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpojer committed Jun 28, 2024
1 parent 510b0c7 commit a403ed6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/github_integration/github_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def get_instance(*args, **kwargs):

@singleton
class GithubManager:
RATE_LIMIT_THRESHOLD_PERCENTAGE = 10 # Start sleeping logic when less than 10% of rate limit remains

"""
A singleton class used to manage GitHub interactions.
"""
Expand Down Expand Up @@ -219,7 +221,8 @@ def show_rate_limit(self):

rate_limit: RateLimit = self.__g.get_rate_limit()

if rate_limit.core.remaining < rate_limit.core.limit/10:
threshold = rate_limit.core.limit * self.RATE_LIMIT_THRESHOLD_PERCENTAGE / 100
if rate_limit.core.remaining < threshold:
reset_time = rate_limit.core.reset
sleep_time = (reset_time - datetime.utcnow()).total_seconds() + 10
logging.debug(f"Rate limit reached. Sleeping for {sleep_time} seconds.")
Expand Down

0 comments on commit a403ed6

Please sign in to comment.