Is it possible to run some long tasks in IPython Notebook, close browser and then after some time open it again and reveal results of these tasks?
Say, task like this:
def f():
import time
time.sleep(100)
with open("result.txt", "w") as fh:
fh.write("Done.")
If I run task normally, and close browser before completion, as I open it back, I see no 'result.txt'
.
If I run it using %px
magic or parallel execution - again no result if I close browser before completion.
Any extensions or hacks available? Or am I missing something?
UPDATE 1:
Although there is background jobs control support in IPython, background jobs become stale after I disconnect browser.
The only thing I could come up with is issuing %connect_info
before closing browser, and then connect from screen terminal using
ipython console --existing <ID>.json
and run my jobs from there.
UPDATE 2:
Even more helpful hack is combination of ipython console
and job control. I.e. I open console and attach to the same session while starting background job in browser and then I'm free to close it until job is finished.
UPDATE 3:
it seems to work since version iPython 1.0dev without any hacks. you just run what you want, close browser and it still runs.