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/nested_context_wait.py

30 lines
927 B
Python

import aiosched
from raw_wait import child
async def main(
children_outer: list[tuple[str, int]], children_inner: list[tuple[str, int]]
):
async with aiosched.with_context() as ctx:
before = aiosched.clock()
print("[main] Spawning children in first context")
for name, delay in children_outer:
await ctx.spawn(child, name, delay)
print("[main] Children spawned")
async with aiosched.with_context() as ctx2:
print("[main] Spawning children in second context")
for name, delay in children_inner:
await ctx2.spawn(child, name, delay)
print("[main] Children spawned")
print(f"[main] Children exited in {aiosched.clock() - before:.2f} seconds")
if __name__ == "__main__":
aiosched.run(
main,
[("first", 1), ("second", 2)],
[("third", 3), ("fourth", 4)],
debugger=None,
)