I was wondering if there is a way to pause/suspend a running Jupyter kernel from the Notebook interface? I was looking for a "Pause" button but couldn't find any.
Use case: Imagine you're working on a laptop, and have a long-running computation at work. Then it would be nice to suspend the kernel's activity when the battery gets drained.
Thanks for filing. I think this should be straightforward on Unix systems, using SIGSTOP (or SIGTSTP if we want to give the kernel the option to ignore it) and SIGCONT. These could be exposed as kernel actions in the REST API, like interrupt and restart already are. I don't know if Windows has an equivalent, but if someone builds a Unix-only solution and leaves the actions as no-ops on Windows, I don't think we'd hold it up.
Maybe relevant for Windows side: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686342(v=vs.85).aspx
I ll check this out, if no one is working on it.
I don't think anyone is. The place to start will be in the jupyter_client package, adding API functions to pause and continue a kernel's execution.
Hey, I see there hasn't been any update on this in a while. I've been checking out the jupyter_client package and working out where to add the API pause/continue functions. However, could anyone point me towards the right directory to go about adding a new button to the top bar of a notebook? I think the best way to do it is to have a separate button controlling SIGTSTP and SIGCONT and leave the current Run and Interrupt buttons as is.
I probably wouldn't put this in the toolbar for now: it's likely to be Unix only, and I'm not sure how reliably it will work. In terms of the UI, I'd probably start by making it an action (see actions.js) so that people can assign it custom shortcuts. But the APIs have to be built before anyone can add UI for it.
Understandable, I'll go there and check it out. Is there a preference between having one action that both suspends the process if it is running AND continues the process if it has been suspended, or two separate actions to achieve the same thing?
It's not a strong preference, but I'd lean towards two separate actions. We can always add a separate toggle action afterwards.
Any updates on this one? @sunpope and @Madhu94 - has either of you made any progress on this?
Guys, I am working on this with PR 3739. Thanks.
@arovit, I tested https://github.com/jupyter/notebook/pull/3739 with some pytorch/cuda long running code - seems to pause and resume just fine.
As far as usability goes, you probably don't need 2 buttons - one Pause/Resume toggle button should suffice as it'll mimic the hardware Play/Pause button we are so used to.
Plus, it would help to indicate somewhere at the menu level (always visible) that the execution thread is paused (perhaps in some color), (or perhaps the bg of the notebook itself change?), because I can see someone hitting the Pause button/menu item by mistake or on purpose and forgetting they did that, and then wonder why nothing works. Perhaps any attempts to execute cells while in that suspended mode should complain too, asking to resume first?
Thank you!
Thanks @stas00 for testing out and sharing this great feedback.
I agree with your suggestions (toggle button and some kind of notifier for kernel pausing) and will start making frontend changes. Right now, I am not 100% sure about what's the best/right thing to do when a user is trying to execute cells on a paused kernel, so for now I will keep this open ended while implementing first two.
I am not 100% sure about what's the best/right thing to do when a user is trying to execute cells on a paused kernel
I thought of changing the background of all cells to a different color indicating this different state. But then I remembered the themes extension, which would make this complicated, as unless that extension is brought in sync with such change, some color conflict may happen.
Probably, for now leaving the cells as they are is fine - as it is will just turn [*] waiting/busy flag on and perhaps, that'd be enough.
It'd be good to hear an opinion from the developers so that you don't waste time designing something that won't be accepted at the end.
Thank you for your work, Arovit.
@arovit: Thank you for the amazing contribution and @stas00: thank you for taking the time for testing the changes out.
@takluyver: Can you please tell us when can we have this feature rolled out?
We're on the cusp of releasing notebook 5.6, so I don't want to merge a new feature like this just before a release. After the release is done, hopefully quite soon.
Guys, I just updated the changes based on all the great feedbacks I received. Updates are to disable these options on Windows, toggle between pause and resume option and showing a notification for paused kernel in the notification bar. As always, looking forward to the feedbacks.


Verified it to work as discussed earlier. Thank you, @arovit!
wrt to placement - would it be functionally logical to put it next to Interrupt in the Kernel submenu?
Now, I've noticed that the Kernel sub-menu appears to be almost sorted alphabetically (but not exactly). So, perhaps, it's another reason to place it in 2nd place?
Thanks @stas00 . I just pushed a commit which adds a selenium testcase for testing this feature and also made changes to have pausing/resume options right next to Interrupt in the kernel submenu. Please let me know if there is anything else I need to work on. Thanks.
Hello, Gentle ping to get some traction on the PR. Thanks !
Just for reference, I found that if I wanted to pause the script running in Jupyter notebook and resume it later, CTRL+S ended up working well for me (although this must be performed in the Anaconda terminal).
Thanks
just chiming to say i googled how to pause a notebook and ended up here! hope the feature's live sometime!
From the Linux shell, you can do Ctrl+Z to pause, then fg jupyter notebook to resume.
@arovit thank you for implementing the feedback.
@stas00 thank you for testing and sharing feedback.
@arovit I see that there is some merge conflict on your PR (on the test case), that is probably what is delaying your PR to be merged.
Eagerly waiting for this feature to be released.
@arovit and @stas00 Thanks a lot for this feature! I was wondering if you are also planning to implement this for jupyter lab? On jupyter lab, there does not seem to be a Pause and Resume option. Thanks in advance for a quick reply!

In which version of jupyter notebooks is this implemented? I just checked because I have this issue with a time consuming process and I would love to have this feature.
I'm in MacOS 10.14.5
This work is still WIP: https://github.com/jupyter/notebook/pull/3739
Hi everyone,
I'm seeking a project to contribute to for one of my college courses. I was curious if there is anything going on in this feature that I could help with? I use Anaconda/Jupyter all the time and would really appreciate the opportunity to give back.
Is this still being worked on? If not I am happy to step in and contribute...
Most helpful comment
Hello, Gentle ping to get some traction on the PR. Thanks !