Skip to content

Feature: support detecting rate limit exceeded #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 8, 2024

Conversation

schelv
Copy link
Contributor

@schelv schelv commented Jan 5, 2024

I've added a RateLimitExceededError class.
This exception provides the time you have to wait before retrying, which simplifies implementing rate limiting.

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (8a381cb) 75.60% compared to head (3b8ee2a) 35.22%.
Report is 2 commits behind head on master.

Files Patch % Lines
githubkit/core.py 28.57% 20 Missing ⚠️
githubkit/exception.py 71.42% 2 Missing ⚠️
githubkit/graphql/__init__.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master      #80       +/-   ##
===========================================
- Coverage   75.60%   35.22%   -40.39%     
===========================================
  Files         541     2414     +1873     
  Lines       59462   124872    +65410     
===========================================
- Hits        44957    43987      -970     
- Misses      14505    80885    +66380     
Flag Coverage Δ
unittests 35.22% <40.00%> (-40.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@schelv schelv force-pushed the RateLimitExceededError branch from 0ded6d5 to 4e57b95 Compare January 5, 2024 18:36
@yanyongyu yanyongyu added the enhancement New feature or request label Jan 6, 2024
@yanyongyu
Copy link
Owner

@schelv i have made some changes to make the handle clearly. Could you please re-check this to ensure the handle is corrent? Thanks a lot.

@yanyongyu
Copy link
Owner

It seems the graphql rate limit is not handled.

@schelv
Copy link
Contributor Author

schelv commented Jan 7, 2024

It seems the graphql rate limit is not handled.

They give a HTTP 200 status code when you exceed that limit 🤦‍♂️
https://docs.github.com/en/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api#exceeding-the-rate-limit

Maybe this? 😄

        if response.is_error:
            # check for errors.
            ....
        else:
            # also check for errors.
            ...

@yanyongyu
Copy link
Owner

For graphql, according to the octokit throttling plugin, an error with RATE_LIMITED type will be returned when primary rate limit exceeded. i'm not sure if this will cover all cases (secondary rate limit). this may be improved in the feature.

@schelv
Copy link
Contributor Author

schelv commented Jan 8, 2024

Looks good!
What to do with the checks that are failing?

@yanyongyu
Copy link
Owner

Don't worry about the reduced coverage, this is an imperfect test and is only used to ensure that it can run.

@yanyongyu yanyongyu changed the title add RateLimitExceededError Feature: support detecting rate limit exceeded Jan 8, 2024
@yanyongyu yanyongyu merged commit 8da991a into yanyongyu:master Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants