-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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()
raise Also 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 |
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
The text was updated successfully, but these errors were encountered: