Created
May 23, 2018 17:11
-
-
Save Guilouf/9220af6cccefbe41bf5e981aa6f4886b to your computer and use it in GitHub Desktop.
A l'arrache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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