Quitting interfaces¶
- sage.interfaces.quit.expect_quitall(verbose=False)[source]¶
EXAMPLES:
sage: sage.interfaces.quit.expect_quitall() sage: gp.eval('a=10') # needs sage.libs.pari '10' sage: gp('a') # needs sage.libs.pari 10 sage: sage.interfaces.quit.expect_quitall() sage: gp('a') # needs sage.libs.pari a sage: sage.interfaces.quit.expect_quitall(verbose=True) # needs sage.libs.pari Exiting PARI/GP interpreter with PID ... running .../gp --fast --emacs --quiet --stacksize 10000000
>>> from sage.all import * >>> sage.interfaces.quit.expect_quitall() >>> gp.eval('a=10') # needs sage.libs.pari '10' >>> gp('a') # needs sage.libs.pari 10 >>> sage.interfaces.quit.expect_quitall() >>> gp('a') # needs sage.libs.pari a >>> sage.interfaces.quit.expect_quitall(verbose=True) # needs sage.libs.pari Exiting PARI/GP interpreter with PID ... running .../gp --fast --emacs --quiet --stacksize 10000000
sage.interfaces.quit.expect_quitall() gp.eval('a=10') # needs sage.libs.pari gp('a') # needs sage.libs.pari sage.interfaces.quit.expect_quitall() gp('a') # needs sage.libs.pari sage.interfaces.quit.expect_quitall(verbose=True) # needs sage.libs.pari
- sage.interfaces.quit.invalidate_all()[source]¶
Invalidate all of the expect interfaces.
This is used, e.g., by the fork-based @parallel decorator.
EXAMPLES:
sage: # needs sage.libs.pari sage.symbolic sage: a = maxima(2); b = gp(3) sage: a, b (2, 3) sage: sage.interfaces.quit.invalidate_all() sage: a (invalid Maxima object -- The maxima session in which this object was defined is no longer running.) sage: b (invalid PARI/GP interpreter object -- The pari session in which this object was defined is no longer running.)
>>> from sage.all import * >>> # needs sage.libs.pari sage.symbolic >>> a = maxima(Integer(2)); b = gp(Integer(3)) >>> a, b (2, 3) >>> sage.interfaces.quit.invalidate_all() >>> a (invalid Maxima object -- The maxima session in which this object was defined is no longer running.) >>> b (invalid PARI/GP interpreter object -- The pari session in which this object was defined is no longer running.)
# needs sage.libs.pari sage.symbolic a = maxima(2); b = gp(3) a, b sage.interfaces.quit.invalidate_all() a b
However the maxima and gp sessions should still work out, though with their state reset:
sage: a = maxima(2); b = gp(3) # needs sage.libs.pari sage.symbolic sage: a, b # needs sage.libs.pari sage.symbolic (2, 3)
>>> from sage.all import * >>> a = maxima(Integer(2)); b = gp(Integer(3)) # needs sage.libs.pari sage.symbolic >>> a, b # needs sage.libs.pari sage.symbolic (2, 3)
a = maxima(2); b = gp(3) # needs sage.libs.pari sage.symbolic a, b # needs sage.libs.pari sage.symbolic
- sage.interfaces.quit.is_running(pid)[source]¶
Return
True
if and only if there is a process with id pid running.
- sage.interfaces.quit.kill_spawned_jobs(verbose=False)[source]¶
INPUT:
verbose
– boolean (default:False
); ifTrue
, display a message each time a process is sent a kill signal
EXAMPLES:
sage: gp.eval('a=10') # needs sage.libs.pari '10' sage: sage.interfaces.quit.kill_spawned_jobs(verbose=False) sage: sage.interfaces.quit.expect_quitall() sage: gp.eval('a=10') # needs sage.libs.pari '10' sage: sage.interfaces.quit.kill_spawned_jobs(verbose=True) # needs sage.libs.pari Killing spawned job ...
>>> from sage.all import * >>> gp.eval('a=10') # needs sage.libs.pari '10' >>> sage.interfaces.quit.kill_spawned_jobs(verbose=False) >>> sage.interfaces.quit.expect_quitall() >>> gp.eval('a=10') # needs sage.libs.pari '10' >>> sage.interfaces.quit.kill_spawned_jobs(verbose=True) # needs sage.libs.pari Killing spawned job ...
gp.eval('a=10') # needs sage.libs.pari sage.interfaces.quit.kill_spawned_jobs(verbose=False) sage.interfaces.quit.expect_quitall() gp.eval('a=10') # needs sage.libs.pari sage.interfaces.quit.kill_spawned_jobs(verbose=True) # needs sage.libs.pari
After doing the above, we do the following to avoid confusion in other doctests:
sage: sage.interfaces.quit.expect_quitall()
>>> from sage.all import * >>> sage.interfaces.quit.expect_quitall()
sage.interfaces.quit.expect_quitall()
- sage.interfaces.quit.register_spawned_process(pid, cmd='')[source]¶
Write a line to the
spawned_processes
file with the givenpid
andcmd
.
- sage.interfaces.quit.sage_spawned_process_file()[source]¶
EXAMPLES:
sage: from sage.interfaces.quit import sage_spawned_process_file sage: len(sage_spawned_process_file()) > 1 True
>>> from sage.all import * >>> from sage.interfaces.quit import sage_spawned_process_file >>> len(sage_spawned_process_file()) > Integer(1) True
from sage.interfaces.quit import sage_spawned_process_file len(sage_spawned_process_file()) > 1