expense-bot/utils/misc/throttling.py

17 lines
362 B
Python
Raw Normal View History

2022-04-01 21:02:03 +02:00
def rate_limit(limit: int, key=None):
"""
Decorator for configuring rate limit and key in different functions.
:param limit:
:param key:
:return:
"""
def decorator(func):
setattr(func, 'throttling_rate_limit', limit)
if key:
setattr(func, 'throttling_key', key)
return func
return decorator