Skip to content

Commit 944f9bd

Browse files
committed
sagemath#26968: add a doctest to catch ecl race in maxima init
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.
1 parent 05329f6 commit 944f9bd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/sage/interfaces/maxima_lib.py

+19
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@
7777
sage: bar == foo
7878
True
7979
80+
TESTS:
81+
82+
Check our workaround for a race in ecl works, see :trac:`26968`.
83+
We use a temporary `MAXIMA_USERDIR` so it's empty; we place it
84+
in `DOT_SAGE` since we expect it to have more latency than `/tmp`.
85+
86+
sage: import tempfile, subprocess
87+
sage: tmpdir = tempfile.TemporaryDirectory(dir=DOT_SAGE)
88+
sage: _ = subprocess.run(['sage', '-c', f'''
89+
....: import os
90+
....: os.environ["MAXIMA_USERDIR"] = "{tmpdir.name}"
91+
....: if not os.fork():
92+
....: import sage.interfaces.maxima_lib
93+
....: else:
94+
....: import sage.interfaces.maxima_lib
95+
....: os.wait()
96+
....: ''']) # long time
97+
sage: tmpdir.cleanup()
98+
8099
"""
81100

82101
# ****************************************************************************

0 commit comments

Comments
 (0)