Skip to content

Commit

Permalink
Add async sleep sort
Browse files Browse the repository at this point in the history
  • Loading branch information
hvnsweeting committed Oct 20, 2018
1 parent 5745e2c commit 95530c1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Python/sleep_sort_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Sleep sort - in asyncio Python 3.6
import asyncio


async def dosleep(i):
await asyncio.sleep(i)
print(i)


loop = asyncio.get_event_loop()
loop.run_until_complete(
asyncio.gather(
*[dosleep(i) for i in [8, 4, 1, 3, 7]]
)
)
loop.close()

0 comments on commit 95530c1

Please sign in to comment.