Last active
July 10, 2016 17:31
-
-
Save aaossa/b0e77fd60b544070bff457765a07cea7 to your computer and use it in GitHub Desktop.
Simple Python 3.5 asyncio base
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 | |
async def slow_operation(n): | |
await asyncio.sleep(n) | |
print("{} Slow operation complete".format(n)) | |
async def main(): | |
await asyncio.wait([slow_operation(1), | |
slow_operation(2), | |
slow_operation(3)]) | |
if __name__ == '__main__': | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment