Skip to content

Instantly share code, notes, and snippets.

@singulared
Created February 27, 2018 12:15
Show Gist options
  • Save singulared/c62b43ac4cf76ed042d31aa7c71aa682 to your computer and use it in GitHub Desktop.
Save singulared/c62b43ac4cf76ed042d31aa7c71aa682 to your computer and use it in GitHub Desktop.
ensure_future scheduled corotine
import asyncio
async def d():
print('d start')
await asyncio.sleep(2)
print('d stop')
async def f():
print('f start')
asyncio.ensure_future(d())
await asyncio.sleep(3)
print('f stop')
loop = asyncio.get_event_loop()
loop.run_until_complete(f())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment