Skip to content

Instantly share code, notes, and snippets.

@Guilouf
Created May 23, 2018 17:11
Show Gist options
  • Save Guilouf/9220af6cccefbe41bf5e981aa6f4886b to your computer and use it in GitHub Desktop.
Save Guilouf/9220af6cccefbe41bf5e981aa6f4886b to your computer and use it in GitHub Desktop.
A l'arrache
import asyncio
async def lent(ind, string):
a = 1
# for i in range(ind): #en fait vu que c'est single thread, le calcul se fait à la queulelle
# a **= 2
await asyncio.sleep(ind)
print("funlent", string)
return a
async def slow_operation(n, string):
await lent(n, string)
async def main():
await asyncio.wait([
slow_operation(10_000_000, 'lent'),
slow_operation(1, 'rap'),
])
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment