From 47651eaf91545adba6ff0927a53751489ce54e35 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 17 Jan 2021 21:24:43 -0500 Subject: [PATCH] Contain the error --- examples/parallelism/we_are_processes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/parallelism/we_are_processes.py b/examples/parallelism/we_are_processes.py index ac4b594..8283b9c 100644 --- a/examples/parallelism/we_are_processes.py +++ b/examples/parallelism/we_are_processes.py @@ -1,6 +1,6 @@ """ Run with a process monitor from a terminal using: -$TERM -e watch -n 0.1 "pstree -a $$" & python examples/parallelism/we_are_processes.py || kill $! +$TERM -e watch -n 0.1 "pstree -a $$" & python examples/parallelism/we_are_processes.py && kill $! """ from multiprocessing import cpu_count @@ -11,7 +11,7 @@ import trio async def target(): - print(f"Yo, i'm {tractor.current_actor().name} " + print(f"Yo, i'm '{tractor.current_actor().name}' " f"running in pid {os.getpid()}") await trio.sleep_forever() @@ -31,4 +31,7 @@ async def main(): if __name__ == '__main__': - trio.run(main) + try: + trio.run(main) + except Exception: + print('Zombies Contained')