Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P7307
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Addshore
on Jun 27 2018, 2:37 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F22725166:
Jun 27 2018, 2:37 PM
2018-06-27 14:37:16 (UTC+0)
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"
)
Event Timeline
Addshore
created this paste.
Jun 27 2018, 2:37 PM
2018-06-27 14:37:16 (UTC+0)
Log In to Comment