-
Notifications
You must be signed in to change notification settings - Fork 160
Open
Description
Sometimes you need to limit API calls from another package that you do not control. In this case, monkey patching the API may be the best option. But where? In the requests package, calls to .get, .head, and other methods of a Request() object are funneled to self.request(), so that is one possibility.  However, that method creates a temporary Session object and sends all invocations through it. As a result, the best way to limit all API calls is:
throttled = limits(calls=15, period=FIFTEEN_MINUTES)
Session.request = throttled(Session.request)
Metadata
Metadata
Assignees
Labels
No labels