Created
July 15, 2020 16:51
-
-
Save werpu/d6b88e4933f93e7571aef435e0cbf03a 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
import asyncio | |
stop_var = False | |
async def task2(): | |
while not stop_var: | |
print("task2") | |
await asyncio.sleep(1) | |
async def task1(): | |
while not stop_var: | |
print("task1") | |
await asyncio.sleep(0.5) | |
async def starter(): | |
t1 = asyncio.create_task(task1()) | |
t2 = asyncio.create_task(task2()) | |
await t1 | |
await t2 | |
asyncio.run(starter()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment