[+] Optimized async test

This commit is contained in:
Charles Le Maux 2024-09-06 17:37:41 +02:00
parent aa792183ab
commit a0a2a8cf43

View File

@ -10,21 +10,21 @@ def ban_user(user_id: str):
print("Error banning user " + user_id, "|", str(e), type(e).__name__) print("Error banning user " + user_id, "|", str(e), type(e).__name__)
async def one(nb: int) -> int: async def one() -> int:
return 1 return 1
async def two(nb: int) -> int: async def two() -> int:
await asyncio.sleep(2) await asyncio.sleep(2)
return 2 return 2
async def three(nb: int) -> int: async def three() -> int:
await asyncio.sleep(3) await asyncio.sleep(3)
return 3 return 3
coroutines = [ coroutines = [
two(1),one(0),three(2), one(),
two(),
three()
] ]
async def main() -> None: async def main() -> None:
results = await asyncio.gather(*coroutines) results = await asyncio.gather(*coroutines)