Skip to content

Instantly share code, notes, and snippets.

@haranicle
Created July 10, 2019 07:16
Show Gist options
  • Save haranicle/92644098879aa3344f5fa981d88784b7 to your computer and use it in GitHub Desktop.
Save haranicle/92644098879aa3344f5fa981d88784b7 to your computer and use it in GitHub Desktop.
import asyncio
async def sleep(s):
await asyncio.sleep(s)
print("🍣")
print(s)
return s
if __name__ == '__main__':
loop = asyncio.get_event_loop()
# loop.run_until_complete(sleep(5))
coros = [sleep(3), sleep(2)]
futures = asyncio.gather(*coros)
loop.run_until_complete(futures)
print("🐟")
print(futures.result())
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment