ratelimit icon indicating copy to clipboard operation
ratelimit copied to clipboard

Optimize Sleep Time for Multiple Limits

Open deckar01 opened this issue 4 years ago • 1 comments

Chaining limits causes waiting processes to wake early and churn.

deckar01 avatar Mar 24 '20 14:03 deckar01

The RateLimitDecorator could inspect the func in __call__ and determine if it is a compatible wrapper with attributes like __func__ and __limits__. It could then discard the previously wrapped func, wrap the original __func__, and append the previous __limits__ to its own instance. Then sleep time can be computed as the maximum period remaining of all limits.

deckar01 avatar Mar 25 '20 18:03 deckar01