-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Sending requests to the GitHub API too quickly will result in abuse rate limit errors. This has been discussed in several issues here (#1235, #2113, #2005, #1319, #1115, #810). I'd like to propose to wrap the Requester.__requestRaw method in a throttling method that ensures subsequent calls are at least a configured number of (float) seconds apart. This way the user of the client library can rely on calls not being too frequent.
Throttling in user code adds complexity on top of the client library and duplicates code across projects that use this client library. A good example is clockfort/GitHub-Backup#44. Especially when iterating over paginated results, throttling becomes difficult in user code.
I have wrapped the Requester.__requestRaw
method with the following code, which allows me to configure seconds between read (GET
) and write (all verbs other than GET
) requests. All requests will then be deferred by the client library if called too quickly:
I am delaying retrys by a urllib Retry
instance with a backoff factor identical to the configured delays above, which is out of scope of this issue.