Fred Gruber wrote:
I actually would like to continue working in the same worksheet while
the computation happens in the background. I remember trying somethign
similar in Ipython where I could use certain parallel libraries to do
exactly that. Every once in a while I could check the status of the run.
Well, if I'm not mistaken, you can do all kinds of weird (or less weird)
stuff in a (Python) notebook cell as you can do in Python, such as
os.system("my_command >/path/to/logfile &") # returns immediately
and continually (try to) read the logfile from another cell.
Using Python's multiprocessing should also work.
Not sure whether Sage's @parallel decorators play well in the notebook
(and the master process/computation won't return until the children have
finished AFAIK, so it's not asynchronous to the evaluation of other cells).
-leif
On Monday, June 2, 2014 7:31:48 AM UTC-4, P Purkayastha wrote:
On Monday, June 2, 2014 8:39:32 AM UTC+8, William wrote:
On Sun, Jun 1, 2014 at 5:26 PM, Fred Gruber <fgr...@gmail.com>
wrote:
> Hello
> Is it possible to run a process in the background in a sage
notebook?
>
> I would like to run a process that takes a long time in the
background and
> just print the status in a log file. This way I could
continue working on
> the notebook on other stuff and check the log file once in a
while.
>
> How to do this?
In SageMathCloud (https://cloud.sagemath.com) I figured out how
to do
this (due to somebody else's request) and implemented it. You put
%fork at the top of a cell, and it will start running as a separate
forked off process in the background:
%fork
sleep(5)
a = 10
When that cell terminates, any global variables it set will get
set in
your worksheet, as long as they are pickle-able. In particular,
the
above will set a to 10, after 5 seconds.
This functionality is not available in sagenb.org
<http://sagenb.org> or the notebook that
comes with Sage, and very likely not with ipython. It required
some
nontrivial special UI support, so wouldn't be trivial to port.
Why not? If I understand correctly, the OP wants to run a
computation without having to keep the browser open (or wants to
navigate away to a different worksheet).
If you run the sagenb notebook as a server, then it will continue
running until one explicitly quits the worksheet or server. Each
worksheet has its own sage process. So, it is entirely possible to
let a worksheet continue running (and computing something), while we
close the browser or navigate away to a different worksheet.
For example, we can start the notebook in a screen session like this:
sage -n interface='' automatic_login=False
and then connect to localhost from the browser, start a worksheet
and a computation in the worksheet. Then we can simply close the tab
containing the worksheet. Later we can reconnect to the local server
and access the worksheet again.
--
() The ASCII Ribbon Campaign
/\ Help Cure HTML E-Mail
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.