Skip to content

add extra time tolerance to a doctest in src/sage/doctest/util.py #40059

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

Merged
merged 1 commit into from
May 11, 2025

Conversation

dcoudert
Copy link
Contributor

@dcoudert dcoudert commented May 7, 2025

This should fix an issue that regularly makes some CI fail.
For instance https://github.com/sagemath/sage/actions/runs/14820026479/job/41605704677?pr=39755#step:12:3011

sage -t --warn-long 5.0 --random-seed=314994774945004744184521593085130720001 src/sage/doctest/util.py
**********************************************************************
Error: Failed example:: Got: 
cysignals.signals.AlarmInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 730, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.doctest.util.inaccuracy_tolerance[4]>", line 1, in <module>
    with ensure_interruptible_after(Integer(1)):  # not passing max_wait_after_interrupt will raise an error
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/util.py", line 894, in ensure_interruptible_after
    raise RuntimeError(
RuntimeError: Function is not interruptible within 1.0000 seconds, only after 1.6246 seconds

    with ensure_interruptible_after(1):  # not passing max_wait_after_interrupt will raise an error
        check_interrupt_only_occasionally()
Expected:
    Traceback (most recent call last):
    ...
    RuntimeError: Function is not interruptible within 1.0000 seconds, only after 1.60... seconds
Got:
    <BLANKLINE>
    cysignals.signals.AlarmInterrupt
    <BLANKLINE>
    During handling of the above exception, another exception occurred:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.doctest.util.inaccuracy_tolerance[4]>", line 1, in <module>
        with ensure_interruptible_after(Integer(1)):  # not passing max_wait_after_interrupt will raise an error
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/contextlib.py", line 158, in __exit__
        self.gen.throw(value)
      File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/util.py", line 894, in ensure_interruptible_after
        raise RuntimeError(
    RuntimeError: Function is not interruptible within 1.0000 seconds, only after 1.6246 seconds

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented May 7, 2025

Documentation preview for this PR (built with commit c8d4d12; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729
Copy link
Contributor

user202729 commented May 8, 2025

probably not the root cause but… at least it works? Would be nice if someone actually figure out the root cause, but for now this is good enough.

On the other hand there's another test that occasionally fails there (I think it's something about the alarm apparently being not raised)

@dcoudert
Copy link
Contributor Author

dcoudert commented May 9, 2025

Thank you for the review. I agree with you that this is certainly not the root cause. At least we will get fewer failing doctests for now.

@vbraun vbraun merged commit 97993c4 into sagemath:develop May 11, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants