Graceful cancel actors before hard reaping

faster_daemon_cancels
Tyler Goodlet 2021-11-25 17:14:16 -05:00
parent 121f7fd844
commit 7eb465a699
1 changed files with 11 additions and 1 deletions

View File

@ -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.
await proc.wait() try:
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