Sage @fork Parallel Decorator Breaking Interface to Singular
Exception raised by child process with pid=1704:
Traceback (most recent call last):
File "/opt/sagemath-8.8/local/lib/python2.7/site-packages/sage/parallel/use_fork.py", line 177, in __call__
self._subprocess(f, dir, *v0)
File "/opt/sagemath-8.8/local/lib/python2.7/site-packages/sage/parallel/use_fork.py", line 302, in _subprocess
value = f(*args, **kwds)
File "<ipython-input-9-532b53e3019b>", line 167, in master
reduktion = reduction(polynomial)
File "<ipython-input-9-532b53e3019b>", line 94, in reduction
singular.set_ring(currentRing)
File "/opt/sagemath-8.8/local/lib/python2.7/site-packages/sage/interfaces/singular.py", line 1098, in set_ring
self.eval("setring %s; short=0"%R.name(), allow_semicolon=True)
File "/opt/sagemath-8.8/local/lib/python2.7/site-packages/sage/interfaces/singular.py", line 658, in eval
raise SingularError('Singular error:\n%s'%s)
SingularError: Singular error:
? sage1317 is no name of a ring/qring
? error occurred in or before STDIN line 11: `setring sage1317; short=0;`
I've been implementing parallelism on a program built in Sage MATH using its interface to Singular. I am attempting to use Sage's @fork parallel decorator, which seems to cause issues with Singular (this error does not occur if the decorator is not present). I'm very new to parallelism and am unsure what the issue here could be. Thanks for any and all help! :D
Interfaces and "fork" don't mix. If it works at all, you'll end up with two processes interfacing with the same pipe (the parent and the child process). Apart from causing issues when both send commands, there's going to be the even more severe issue of it being undetermined which of the two processes will be consuming output from the singular process as it becomes available.
What should be workable is to create a new singular interface after forking. That will be a private singular process for your fork child.
Thanks for the comment! I'm not totally sure what you mean by create a new singular interface, in my code I've just been using singular.<command>. I can post my code if that would be illuminating. I assumed that each call to Singular via Sage was a new instance of the interface, but maybe that is a misinterpretation.