This repository has been archived on 2023-05-12. You can view files and clone it, but cannot push or open issues or pull requests.
aiosched/tests/context_wait.py

17 lines
530 B
Python
Raw Normal View History

2022-10-18 17:26:58 +02:00
import aiosched
from raw_wait import child
2022-10-18 17:26:58 +02:00
async def main(children: list[tuple[str, int]]):
print("[main] Spawning children")
2023-04-28 16:04:30 +02:00
async with aiosched.create_pool() as ctx:
2022-10-18 17:26:58 +02:00
for name, delay in children:
await ctx.spawn(child, name, delay)
2022-10-19 11:31:45 +02:00
print("[main] Children spawned")
2022-10-18 17:26:58 +02:00
before = aiosched.clock()
print(f"[main] Children exited in {aiosched.clock() - before:.2f} seconds")
if __name__ == "__main__":
aiosched.run(main, [("first", 1), ("second", 2), ("third", 3)], debugger=None)