mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] Optimized async test
This commit is contained in:
parent
aa792183ab
commit
a0a2a8cf43
12
unit_test.py
12
unit_test.py
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user