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.
2022-10-18 15:55:43 +02:00
|
|
|
import aiosched
|
|
|
|
from debugger import Debugger
|
|
|
|
|
|
|
|
|
2022-11-02 09:28:04 +01:00
|
|
|
async def child_raises(name: str, n: int):
|
2022-10-18 15:55:43 +02:00
|
|
|
before = aiosched.clock()
|
|
|
|
print(f"[child {name}] Sleeping for {n} seconds")
|
|
|
|
await aiosched.sleep(n)
|
2022-11-02 09:28:04 +01:00
|
|
|
print(f"[child {name}] Done! Slept for {aiosched.clock() - before:.2f} seconds, raising now!")
|
2022-10-18 15:55:43 +02:00
|
|
|
raise TypeError("waa")
|
|
|
|
|
|
|
|
|
|
|
|
async def main(n: int):
|
|
|
|
print("[main] Spawning child")
|
2022-11-02 09:28:04 +01:00
|
|
|
task = await aiosched.spawn(child_raises, "raise", n)
|
2022-10-18 15:55:43 +02:00
|
|
|
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")
|
|
|
|
|
|
|
|
|
2022-10-18 17:26:58 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
aiosched.run(main, 5)
|