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_silent_catch.py

22 lines
676 B
Python

import aiosched
from raw_catch import child
async def main(children: list[tuple[str, int]]):
async with aiosched.with_context(silent=True) as ctx:
print("[main] Spawning children")
for name, delay in children:
await ctx.spawn(child, name, delay)
print("[main] Children spawned")
before = aiosched.clock()
if ctx.exc:
print(
f"[main] Child raised an exception -> {type(ctx.exc).__name__}: {ctx.exc}"
)
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)