Skip to content

Instantly share code, notes, and snippets.

@DannyMor
Last active April 20, 2020 15:38
Show Gist options
  • Save DannyMor/2609a4798e3655ba0851b5a99ffb9a60 to your computer and use it in GitHub Desktop.
Save DannyMor/2609a4798e3655ba0851b5a99ffb9a60 to your computer and use it in GitHub Desktop.
@asynccontextmanager
async def throttle(self) -> None:
await self.semaphore.acquire()
await self.add_token()
try:
yield
finally:
self.semaphore.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment