Last active
April 20, 2020 15:34
-
-
Save DannyMor/8e45affff28d3f6b9e3ac5fc8cc04e1e to your computer and use it in GitHub Desktop.
rate limiter 1
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) -> None: | |
self.rate_limit = rate_limit | |
self.tokens_queue = asyncio.Queue(rate_limit) | |
self.tokens_consumer_task = asyncio.create_task(self.consume_tokens()) | |
async def add_token(self) -> None: | |
pass | |
async def consume_tokens(self) -> None: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment