-
-
Save lanfon72/fa2d2b0725656443e8c27d4b5af9c1d5 to your computer and use it in GitHub Desktop.
asyncio.callback
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 time | |
| import asyncio | |
| def q2(val): | |
| print("delay 1 second") | |
| time.sleep(1) | |
| print(val) | |
| def cb(fut): | |
| r = fut.result() | |
| print(r, "world") | |
| fut._loop.stop() | |
| loop = asyncio.get_event_loop() | |
| fut = loop.run_in_executor(None, q2, "hello") | |
| fut.add_done_callback(cb) | |
| loop.run_forever() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...