Error: Failed example:: Exception raised:
cysignals.signals.AlarmInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run
self.compile_and_execute(example, compiler, test.globs)
File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute
exec(compiled, globs)
File "<doctest sage.matrix.matrix2.Matrix._charpoly_df[19]>", line 1, in <module>
with ensure_interruptible_after(Integer(1)): m.charpoly()
File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/contextlib.py", line 158, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/util.py", line 904, in ensure_interruptible_after
raise RuntimeError(
RuntimeError: Function is not interruptible within 1.0000 seconds, only after 1.2124 seconds
I recently "fixed" two instances of this, and a summary of the discussion is that
Example (from CI):
I recently "fixed" two instances of this, and a summary of the discussion is that
ensure_interruptible_after()is not a priori reliable because it uses wall time. The CPU scheduler is free to put any task to sleep for any amount of time.cputime()asks the subprocesses to account for their time, and some of them don't. The newer CPU timer used for--warn-longrelies on psutil on non-linux platforms, but psutil is standard only in the sage distro and is not a dependency of the sage library. We would also need to adjust the timing based on how fast the CPU is, or pad the numbers.max_wait_after_interruptto something huge, like five seconds. The tests are usually there to ensure thatsig_on()andsig_off()are wrapping some C code, so if we can interrupt something that would finish in ten minutes after only, say, four seconds... it's fine.