Created
February 4, 2019 17:26
-
-
Save BolajiOlajide/b004a4e8ec9b33d66a24d74d13485f96 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 | |
# Borrowed from http://curio.readthedocs.org/en/latest/tutorial.html. | |
@asyncio.coroutine | |
def countdown(number, n): | |
while n > 0: | |
print('T-minus', n, '({})'.format(number)) | |
yield from asyncio.sleep(1) | |
n -= 1 | |
loop = asyncio.get_event_loop() | |
tasks = [ | |
asyncio.ensure_future(countdown("A", 2)), | |
asyncio.ensure_future(countdown("B", 3))] | |
loop.run_until_complete(asyncio.wait(tasks)) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment