Last active
January 3, 2023 21:43
-
-
Save PouyaEsmaeili/fba52cc7ac80ee3f8c11190fdc7a10dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import timedelta | |
from random import choices | |
from redis import StrictRedis | |
from string import ascii_uppercase, ascii_lowercase | |
class RateLimiter(object): | |
def __init__(self, | |
con_pool: StrictRedis, | |
number_of_requests: int, | |
time_bound: timedelta, | |
limit_per_client: bool = False, | |
lock_timeout: float = 0.1, | |
log_value: str = ''): | |
self._con_pool = con_pool | |
self._number_of_requests = number_of_requests | |
self._time_bound = time_bound | |
self._limit_per_client = limit_per_client | |
self._lock_timeout = lock_timeout | |
self._log_value = log_value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment