Page MenuHomePhabricator
Paste P7307

(An Untitled Masterwork)
ActivePublic

Authored by Addshore on Jun 27 2018, 2:37 PM.
Tags
None
Referenced Files
F22725166:
Jun 27 2018, 2:37 PM
Subscribers
None
import asyncio
counter = 0;
should_print = 1;
async def print_ones():
while should_print == 1:
print(1)
counter = counter + 1
if counter > 10:
should_print = 0
await asyncio.sleep(0.1)
async def print_twos():
while should_print == 1:
print(2)
counter = counter + 1
if counter > 10:
should_print = 0
await asyncio.sleep(0.1)
while should_print == 1:
# Wait for the 2 async loops to finish
await asyncio.sleep(0.1)
# Do stuff after the 2 loops
print("Done")