Last active
April 20, 2020 15:37
-
-
Save DannyMor/01c9830a495b690dad83827208bfd81f 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
class RateLimiter: | |
def __init__(self, rate_limit: int, concurrency_limit: int) -> None: | |
self.rate_limit = rate_limit | |
self.tokens_queue = asyncio.Queue(rate_limit) | |
self.tokens_consumer_task = asyncio.create_task(self.consume_tokens()) | |
self.semaphore = asyncio.Semaphore(concurrency_limit) | |
async def add_token(self) -> None: | |
pass | |
async def consume_tokens(self) -> None: | |
pass | |
async def throttle(self) -> None: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment