feat: Semaine 9

This commit is contained in:
gauvainboiche
2026-05-15 16:24:56 +02:00
parent 3315cb2336
commit ce1f0e513a
108 changed files with 3150 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import asyncio
async def coro(numbers):
await asyncio.sleep(min(numbers))
return list(reversed(numbers))
async def main():
task1 = asyncio.create_task(coro= coro([10, 5, 2]))
task2 = asyncio.create_task(coro= coro([3, 2, 1]))
for task in asyncio.as_completed([task1, task2]):
result = await task
print(f"{type(task)=}")
print(result)
if __name__ == "__main__":
asyncio.run(main())
"""
await coro(utine) : exécute immédiatement et attend qu'elle finisse
create_task() : planifie une coroutine en arrière-plan
"""