26 lines
749 B
Python
26 lines
749 B
Python
import aiosched
|
|
from debugger import Debugger
|
|
|
|
|
|
async def child(name: str, n: int):
|
|
before = aiosched.clock()
|
|
print(f"[child {name}] Sleeping for {n} seconds")
|
|
await aiosched.sleep(n)
|
|
print(f"[child {name}] Done! Slept for {aiosched.clock() - before:.2f} seconds")
|
|
raise TypeError("waa")
|
|
|
|
|
|
async def main(n: int):
|
|
print("[main] Spawning child")
|
|
task = await aiosched.spawn(child, "raise", n)
|
|
print("[main] Waiting for child")
|
|
before = aiosched.clock()
|
|
try:
|
|
await aiosched.wait(task)
|
|
except Exception as err:
|
|
print(f"[main] Child raised an exception -> {type(err).__name__}: {err}")
|
|
print(f"[main] Child exited in {aiosched.clock() - before:.2f} seconds")
|
|
|
|
|
|
aiosched.run(main, None, 5)
|