Skip to content

Commit

Permalink
doctest/control.py: add default for die_timeout
Browse files Browse the repository at this point in the history
This was missing in the previous commit.

Also, tune up the timeout in the corresponding test in doctest/test.py.
This prevents a doctest failure when pytest is installed (since then
running `sage -t` will take ~ 3s after the doctest was actually run.

If #33531 is merged, the way we run `sage -t` here (using
`--optional=sage`) avoids the pytest overhead and the timeout can be
tuned down again.
  • Loading branch information
tornaria committed Mar 19, 2022
1 parent 5eb0283 commit 814a2fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self, **kwds):
self.nthreads = 1
self.serial = False
self.timeout = -1
self.die_timeout = -1
self.all = False
self.logfile = None
self.long = False
Expand Down
8 changes: 4 additions & 4 deletions src/sage/doctest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
sage: kwds2 = deepcopy(kwds)
sage: kwds2['env']['DOCTEST_TEST_PID_FILE'] = F # Doctester will write its PID in this file
sage: subprocess.call(["sage", "-tp", "1000000", "--timeout=120", # long time
....: "--die_timeout=4", "--optional=sage",
....: "--die_timeout=10", "--optional=sage",
....: "--warn-long", "0", "99seconds.rst", "interrupt_diehard.rst"], **kwds2)
Running doctests...
Doctesting 2 files using 1000000 threads...
Expand All @@ -251,13 +251,13 @@
Even though the doctester master process has exited, the child process
is still alive, but it should be killed automatically
after the `die_timeout` given above (4 seconds)::
after the `die_timeout` given above (10 seconds)::
sage: pid = int(open(F).read()) # long time
sage: time.sleep(2) # long time
sage: os.kill(pid, signal.SIGQUIT) # long time; 2 seconds passed => still alive
sage: time.sleep(2) # long time
sage: os.kill(pid, signal.SIGQUIT) # long time; 4 seconds passed => dead
sage: time.sleep(8) # long time
sage: os.kill(pid, signal.SIGQUIT) # long time; 10 seconds passed => dead
Traceback (most recent call last):
...
ProcessLookupError: ...
Expand Down

0 comments on commit 814a2fd

Please sign in to comment.