This can be solved using throttled-py.
from datetime import timedelta
from throttled import Throttled, rate_limiter, RateLimiterType
quota = rate_limiter.per_duration(timedelta(minutes=5), limit=5)
# Supports multiple algorithms, use Token Bucket by default.
@Throttled(key="StashNotes", quota=quota)
def StashNotes():
return "StashNotes"
If the limit is exceeded, a LimitedError is thrown: throttled.exceptions.LimitedError: Rate limit exceeded: remaining=0, reset_after=300, retry_after=60.
.