My question is the following: sometimes a computation runs too long, and I would rather for it to stop automatically, and move on to the next computation (in the best possible world keep a list of the cases that were skipped).
So I wanted to implement the solution to this (essentially) identical question:
https://stackoverflow.com/questions/14920384/stop-code-after-time-period
However in my case the function "foo" uses some functionalities of GAP. This apparently causes a crash:
** Gap crashed or quit executing '__SAGE_LAST__:="__SAGE_LAST__";;AllSmallGroups(\$sage1);;' ** Restarting Gap and trying again
The crash happens immediately on the first call of the GAP function.
Is there any way to avoid this?
here is the rest of the error:
Process Foo: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/ptyprocess/ptyprocess.py", line 711, in isalive pid, status = os.waitpid(self.pid, waitpid_options) ChildProcessError: [Errno 10] No child processes During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 23, in _wrap_ptyprocess_err yield File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 705, in isalive alive = ptyproc.isalive() File "/usr/lib/python3/dist-packages/ptyprocess/ptyprocess.py", line 715, in isalive raise PtyProcessError('isalive() encountered condition ' + ptyprocess.util.PtyProcessError: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process? During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 658, in _eval_line (normal, error) = self._execute_line(line, wait_for_prompt=wait_for_prompt, File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 524, in _execute_line x = E.expect_list(self._compiled_full_pattern) File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 372, in expect_list return exp.expect_loop(timeout) File "/usr/lib/python3/dist-packages/pexpect/expect.py", line 169, in expect_loop incoming = spawn.read_nonblocking(spawn.maxread, timeout) File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 478, in read_nonblocking if not self.isalive(): File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 704, in isalive with _wrap_ptyprocess_err(): File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__ self.gen.throw(typ, value, traceback) File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 25, in _wrap_ptyprocess_err raise ExceptionPexpect(*e.args) pexpect.exceptions.ExceptionPexpect: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process? During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 673, in _eval_line raise RuntimeError("%s produced error output\n%s\n executing %s"%(self, error,line)) RuntimeError: Gap produced error output Error, <size> must be a positive integer executing __SAGE_LAST__:="__SAGE_LAST__";;AllSmallGroups(\$sage1);; During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/tmp/ipykernel_115920/3461510396.py", line 85, in dobblegppack A = gap(nn).AllSmallGroups() File "/usr/lib/python3/dist-packages/sage/interfaces/interface.py", line 693, in __call__ return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds) File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 856, in function_call res = self.eval(marker+cmd) File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 498, in eval result = Expect.eval(self, input_line, **kwds) File "/usr/lib/python3/dist-packages/sage/interfaces/expect.py", line 1382, in eval return '\n'.join([self._eval_line(L, allow_use_file=allow_use_file, **kwds) File "/usr/lib/python3/dist-packages/sage/interfaces/expect.py", line 1382, in <listcomp> return '\n'.join([self._eval_line(L, allow_use_file=allow_use_file, **kwds) File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 703, in _eval_line return self._eval_line(line, allow_use_file=allow_use_file) File "/usr/lib/python3/dist-packages/sage/interfaces/gap.py", line 707, in _eval_line raise RuntimeError(exc) RuntimeError: Gap produced error output Error, <size> must be a positive integer executing __SAGE_LAST__:="__SAGE_LAST__";;AllSmallGroups(\$sage1);;