Skip to content

Commit

Permalink
sagemath#26968: add a doctest to catch ecl race in maxima init
Browse files Browse the repository at this point in the history
We use a temporary `MAXIMA_USERDIR` so its empty, and we try
to initialize maxima twice in parallel to entice the race.
This temporary dir is placed within `DOT_SAGE` so it is easy
to try different filesystems.

The bug triggers more frequently if `DOT_SAGE` is in a high
latency filesystem (e.g. sshfs on a non-local host).

The next commit introduces a workaround for the bug.
  • Loading branch information
tornaria committed Feb 21, 2023
1 parent 05329f6 commit 944f9bd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/sage/interfaces/maxima_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@
sage: bar == foo
True
TESTS:
Check our workaround for a race in ecl works, see :trac:`26968`.
We use a temporary `MAXIMA_USERDIR` so it's empty; we place it
in `DOT_SAGE` since we expect it to have more latency than `/tmp`.
sage: import tempfile, subprocess
sage: tmpdir = tempfile.TemporaryDirectory(dir=DOT_SAGE)
sage: _ = subprocess.run(['sage', '-c', f'''
....: import os
....: os.environ["MAXIMA_USERDIR"] = "{tmpdir.name}"
....: if not os.fork():
....: import sage.interfaces.maxima_lib
....: else:
....: import sage.interfaces.maxima_lib
....: os.wait()
....: ''']) # long time
sage: tmpdir.cleanup()
"""

# ****************************************************************************
Expand Down

0 comments on commit 944f9bd

Please sign in to comment.