Created
February 6, 2019 21:21
-
-
Save ankitml/2f4dcd3a4db5fa0f1ff0e79b8966a955 to your computer and use it in GitHub Desktop.
Websockets Tutorial 3 - Two simultaneous heart beats
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
async def beat1(websocket): | |
while True: | |
await asyncio.sleep(1) | |
await websocket.send('💚') | |
async def beat2(websocket): | |
while True: | |
await asyncio.sleep(2) | |
await websocket.send('💓') | |
async def ws_handler(websocket, path): | |
await asyncio.gather(beat1(websocket), beat2(websocket)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment