Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
In run_process, what should happen if the deliver_cancel function raises an exception? #1532
Comments
|
Yeah, this is tricky. On the one hand, you kind of have to report the failure, b/c "program hangs silently" is terrible UX. On the other hand, you kind of can't report the failure, b/c That's why I ended up putting Maybe we should pull the I guess for exceptions out of arbitrary user code, it would be nice to include the full traceback. That's an awkward fit for the In a few other places where we have this kind of problem (instrument failures, |
|
Logging the exception, and still waiting for the process to exit, seems like a good compromise to me. The log message should explicitly say that it's still waiting for the process to exit, so that the reason for the apparent deadlock is as obvious as we can make it. |
|
Hey guys so I'm gonna take a crack at this issue. try:
await proc.wait()
except trio.Cancelled:
with trio.CancelScope(shield=True):
killer_cscope = trio.CancelScope(shield=True)
async def killer():
with killer_cscope:
try: # here is the new try except
await deliver_cancel(proc)
except OSError as exc:
warnings.warn(
RuntimeWarning(
f"tried to kill process {proc!r}, but failed with: {exc!r}"
)
)
nursery.start_soon(killer)
await proc.wait()
killer_cscope.cancel()
raiseAlso what is a good way to trigger an |
You mean
You can also just do: async def custom_deliver_cancel(proc):
raise OSError("whoops!")Also:
|
|
Sorry can you expand on the |
|
@guilledk In your comment, you had |
|
Oh ok got it |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

What should happen if deliver_cancel raises an exception? In the current implementation, the shielded cancel scope will prevent it from propagating until the process exits, which might take a while if the crash occurred before signaling the process in any way. Maybe on exception from a user-specified deliver_cancel we should call the default deliver_cancel to kill the process? Or just kill() since we don't care much about polish at that point, only about letting the user know what they need to fix.
Originally posted by @oremanj in #1525