Skip to content

Instantly share code, notes, and snippets.

@werpu
Created July 15, 2020 16:51
Show Gist options
  • Save werpu/d6b88e4933f93e7571aef435e0cbf03a to your computer and use it in GitHub Desktop.
Save werpu/d6b88e4933f93e7571aef435e0cbf03a to your computer and use it in GitHub Desktop.
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