ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[red-knot] Prevent salsa cancellation from aborting the program

Open MichaReiser opened this issue 1 year ago • 1 comments
trafficstars

Summary

This PR wraps the public-visible Program methods to use Cancelled::catch to prevent that any salsa cancellation tears down its thread.

I honestly don't think this change is safe in Rust terms, but it is what rust-analyzer and other Salsa based compilers to (most implement the UnwindSafe marker trait but I prefer not to do this). I've opened a Zulip thread to get more guidance but, for now, I think this is sufficiently "safe" (I hate this).

Test Plan

I ran red_knot with RED_KNOT_SLOW_LINT=1 which adds an artificial 10s pause to the lint query. The query was correctly cancelled when I made changes to a file in the workspace directory without tearing down the entire rayon thread pool.

MichaReiser avatar Jul 04 '24 09:07 MichaReiser