Skip to content Skip to sidebar Skip to footer

Running A Process In The Background In Jupyter

In a Jupyter notebook, if I run a cell that takes a long time, I cannot run any other cell until the first cell is computed. Is there a way to tell Jupyter to run a cell in a backg

Solution 1:

I tried this using Multiprocessing and found it does not work, I've no idea if this is a limitation of Windows or recent Jupyter/Python.

So instead I created a solution using Threading, based on this work: https://gist.github.com/maartenbreddels/3378e8257bf0ee18cfcbdacce6e6a77e All credit to author of this Gist

This method hooks the 0MQ event loop that IPython uses internally to perform work by submitting callbacks to the same event loop.

I've prepared an example Jupyter Notebook Gist is here: https://gist.github.com/the-moog/94b09b49232731bd2a3cedd24501e23b

This example updates a pair of progress bars asynchronously, you should be able to replace the callback with code that performs other tasks.

(I'm not a fan of links in posts. If anybody knows how to render notebook views directly into stackoverflow, let me know)

Post a Comment for "Running A Process In The Background In Jupyter"