In cysignals
(package used to allow SageMath functions to be interruptable),
the functions sig_on
, sig_off
, sig_on_no_except
are provided.
However, if we want to clean up the resources properly when the code is interrupted, there are several ways to do it. We will compare them by code readability and performance here.
Let's start with some helper code.
This overrides %%cython
magic to the version provided by Cython. This version allows specifying arguments. See also sagemath/sage#38945