Last active
April 16, 2018 19:32
-
-
Save AstraLuma/d9c7222ac78345fd6f641a2b09a61343 to your computer and use it in GitHub Desktop.
Async Talk Code Examples
This file contains hidden or 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 say(what, when): | |
| await asyncio.sleep(when) | |
| print(what) | |
| # print() is already buffered by Python, IPC Pipes, etc | |
| # You should still async it, but it's only going to bite | |
| # when other things go wrong. | |
| loop = asyncio.get_event_loop() | |
| loop.run_until_complete(say('Hello, World!', 1)) | |
| loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment