forked from goodboy/tractor
Graceful cancel actors before hard reaping
parent
121f7fd844
commit
7eb465a699
|
@ -295,7 +295,17 @@ async def new_proc(
|
||||||
# ``trio.Process.__aexit__()`` (it tears down stdio
|
# ``trio.Process.__aexit__()`` (it tears down stdio
|
||||||
# which will kill any waiting remote pdb trace).
|
# which will kill any waiting remote pdb trace).
|
||||||
# This is a "soft" (cancellable) join/reap.
|
# This is a "soft" (cancellable) join/reap.
|
||||||
|
try:
|
||||||
await proc.wait()
|
await proc.wait()
|
||||||
|
except trio.Cancelled:
|
||||||
|
# if cancelled during a soft wait cancel the child
|
||||||
|
# actor before entering the hard reap
|
||||||
|
# sequence below. This means we try to do a
|
||||||
|
# graceful teardown before getting out zombie
|
||||||
|
# killing tools.
|
||||||
|
with trio.CancelScope(shield=True):
|
||||||
|
await portal.cancel_actor()
|
||||||
|
raise
|
||||||
|
|
||||||
# cancel result waiter that may have been spawned in
|
# cancel result waiter that may have been spawned in
|
||||||
# tandem if not done already
|
# tandem if not done already
|
||||||
|
|
Loading…
Reference in New Issue