Skip to content

Instantly share code, notes, and snippets.

@lanfon72
Last active May 17, 2017 15:49
Show Gist options
  • Select an option

  • Save lanfon72/fa2d2b0725656443e8c27d4b5af9c1d5 to your computer and use it in GitHub Desktop.

Select an option

Save lanfon72/fa2d2b0725656443e8c27d4b5af9c1d5 to your computer and use it in GitHub Desktop.
asyncio.callback
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()
@lanfon72
Copy link
Author

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment