Created
March 13, 2020 09:38
-
-
Save alex-eri/9b1a028ce5d12a962957beeba86803b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import asyncio | |
loop = asyncio.get_event_loop() | |
sema = asyncio.Semaphore(value=10) | |
async def send(msg): | |
print(msg) | |
async def income(msg): | |
if not sema.locked(): | |
await sema.acquire() | |
await send(msg) | |
loop.call_later(5, sema.release()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment