Skip to content

Instantly share code, notes, and snippets.

@markrwilliams
Last active February 19, 2017 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markrwilliams/b7a3c5b914d1f207e2250c421760d51c to your computer and use it in GitHub Desktop.
Save markrwilliams/b7a3c5b914d1f207e2250c421760d51c to your computer and use it in GitHub Desktop.
import asyncio
def adapt(the_future):
try:
print("*** result before")
the_future.result()
except:
print("*** exception before")
the_future.exception()
f = asyncio.ensure_future(asyncio.sleep(10))
f.add_done_callback(adapt)
f.cancel()
asyncio.get_event_loop().run_until_complete(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment