You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kernel/Interrupt Kernel does not terminate stuck subprocesses in the notebook #3400
When a subprocess is run from the notebook, if it gets stuck the kernel will get locked waiting for it. Selecting Kernel/Interrupt from the menu does not terminate the subprocess, but rather leaves the kernel in an unstable, "partially locked" state, where other cells do not execute. The only resolution is to restart the kernel.
This occurred for me on Windows - I do not know if it also happens on Unix.
To demonstrate, start a notebook and enter !python in a cell. The process will lock as it is waiting for interactive input. As there is no way to provide that input, the kernel must be restarted to continue.
Reacted by Swapnil Athawale, riley wong, laurathepluralized, Harsha Laxman, Richard Nichol, mueslo, Amarchuk, Peter Mitrano, Andrew Kittredge, Muhammad N ElNokrashy and 58 more
Thanks, I hadn't spotted the duplicate. Having said that, t#514 is discussing a much more complex scenario, involving actually interacting with subprocesses (and it seems to be Unix based, as it's about pty-style interaction). For my requirements, a simple means of killing a rogue subprocess would do. Consider something as simple as !sleep 50000, where just being able to kill the sleep is all you want. (Maybe Ctrl-C works for this on Unix, but it doesn't on Windows).
Reacted by Moobie, Ambareesh S N Jayakumari, Avio, Andreas, Nygration and brl198
I'm not sure this is limited to subprocesses. Try executing input() or raw_input() and then clicking the interrupt button--the kernel hangs and has to be restarted.
Ah, crap. I know what that bug is. I think it's a libzmq (or pyzmq) bug that prevents it from handling interrupts properly while polling on zmq sockets. It's nothing in IPython. sigh
Reacted by Johannes Wienke, Asif Mehedi, Matthias Minderer, Neal McBurnett, i-aztec, Luca Innocenti, Daniel Guggenheim, Jonathan Janke, Kelvin Wang, laurathepluralized and 17 more
This same issue happens for me in Unix as well word for word.
"When a subprocess is run from the notebook, if it gets stuck the kernel will get locked waiting for it. Selecting Kernel/Interrupt from the menu does not terminate the subprocess, but rather leaves the kernel in an unstable, "partially locked" state, where other cells do not execute. The only resolution is to restart the kernel."
Reacted by Ilya Baryshnikov, Lukas Martak, Gopal Rander, Matthias Minderer, i-aztec, Sebastian Böser, Kunyu Shi, laurathepluralized, Moobie, Matthew Drury and 5 more
Reacted by William Lee, Valeria Gomes, Max Kenobi, Chun-fan Ivan Liao, Matthew Drury, naiduaditya-furlenco, Douglas Duhaime and Samuel Talkington
Printing too much data, let's say accidentally printing a gigantic numpy array, can make the kernel completely unresponsive and impossible to to terminate
Reacted by Valeria Gomes, AliengirlLiv, Andreas, Seyyed Hossein Hasanpour, antonellagarzilli, Tom Bertalan, Hatem Oraby and Sohang Chopra
Has a solution been found for this issue yet? i just ran a machine learning model that took 14hr to complete and now my kernel is stuck and doesnt execute cells. if i restart, i have to run the model again for 14hrs. So is there any solution?
Reacted by Angel Ting, kali prasad, laurathepluralized, ClareMa, Marina, Max Kenobi, Vera, Chun-fan Ivan Liao, Andreas, Seyyed Hossein Hasanpour and 22 more
I run into this sometimes too... Here is a reproduceable example from jupyer lab:
LOAD DATA
import requests
import pandas as pd
url='https://raw.githubusercontent.com/numenta/NAB/master/data/realKnownCause/nyc_taxi.csv'
r = requests.get(url, allow_redirects=True)
with open('data/nyc_taxi.csv', 'wb') as f:
f.write(r.content)
df_taxi = (
pd.read_csv('data/nyc_taxi.csv')
.assign(timestamp=lambda x: pd.to_datetime(x.timestamp))
)
df_train = df_taxi.iloc[:5000]
temp_train = df_train.set_index('timestamp')
Run Grid Search: THIS CANNOT BE INTERRUPTED
import itertools
#set parameter range
p = range(0,3)
q = range(1,3)
d = range(1,2)
s = [24,48]
# list of all parameter combos
pdq = list(itertools.product(p, d, q))
seasonal_pdq = list(itertools.product(p, d, q, s))
# SARIMA model pipeline
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(temp_train[:240],
order=param,
seasonal_order=param_seasonal)
results = mod.fit(max_iter = 50, method = 'powell')
print('SARIMA{},{} - AIC:{}'.format(param, param_seasonal, results.aic))
except as e:
print(e)
continue
run into this problem three times this afternoon, reminds me of the good old days when i was still using urllib.
thought its on urllib, cause there is no response to my request.
I was working but coding, I have to find a solution but a answer. So I store every variable to local file.
really don't want to see that happen again and again.
Возникает такая же проблема, и самое интересное в случайных участках кода при использование B0 remote api для coppelia sim. При это если я использую Publisher и Subscriber
Are there any news on this issue? I am working remotely in a Kubernetes pod and, when this occurs, I am completely locked out of the machine. I cannot even open a shell.
@thistlillo your issue is most likely unrelated to this one. In any case, we would need more information than what you've provided, like: version of IPython and Python you're using, whether you are using Jupyter Notebook or Jupyter Lab, versions of those, etc. And, most importantly, a minimalized set of steps required to reproduce the issue.
If you can provide this info, please create a new issue and include it.
I ran into this issue today on my linux laptop. Although I have not found a way to interrupt the kernel, I was able to save my variables by injecting a pickle.dumps using pyrasite. Thanks to https://stackoverflow.com/a/59124617/18638036
Hey guys! I also had the same issue, but it was a silly mistake on my end.
Avoid using try without adding specific exceptions in your except block you are expecting your code to throw. A generic try looks like this -
try:
#code here
except:
#exception handling
It seems like this code would also catches your keyboard Interrupts/ kernel interrupts which registers as KeyboardInterrupt exception (only if execution is inside this try block) .
I thought it might help some unfortunate souls if I share it here.
Its 2025... getting same error, endless cycle of Interrupts kernel dialog while on the children Jupyter notebook to teach adult "programmers" how to program.
Edit:
So need to update VS code and then restart... Jupyter (stuff used to teach kids how to program for "software engineers" 🤣) then doesn't throw the endless "Interrupts kernel dialog". Programmers will get dumb when things are taught via Jupyter, it's so unfortunate.
Activity
minrk commentedon Jun 4, 2013
duplicate of #514
pfmoore commentedon Jun 4, 2013
Thanks, I hadn't spotted the duplicate. Having said that, t#514 is discussing a much more complex scenario, involving actually interacting with subprocesses (and it seems to be Unix based, as it's about pty-style interaction). For my requirements, a simple means of killing a rogue subprocess would do. Consider something as simple as
!sleep 50000, where just being able to kill the sleep is all you want. (Maybe Ctrl-C works for this on Unix, but it doesn't on Windows).minrk commentedon Jun 13, 2013
Sorry, I see what you mean now. Reopening as a separate issue - interrupt not interrupting subprocesses on Windows.
arijun commentedon Sep 17, 2014
I'm not sure this is limited to subprocesses. Try executing
input()orraw_input()and then clicking the interrupt button--the kernel hangs and has to be restarted.minrk commentedon Sep 17, 2014
@arijun on What OS? interrupting input and raw_input raise KeyboardInterrupt here (OS X).
arijun commentedon Sep 18, 2014
Sorry, windows. That's why I thought it was likely the same issue @pfmoore had, since that also happened on windows.
minrk commentedon Sep 18, 2014
Ah, crap. I know what that bug is. I think it's a libzmq (or pyzmq) bug that prevents it from handling interrupts properly while polling on zmq sockets. It's nothing in IPython. sigh
wmayner commentedon Mar 31, 2016
I think I just got bitten by this and I'll need to restart the kernel, meaning I've just lost a lot of data…
I was using
pdbto debug a function. I re-ran the cell without first quittingpdb, and now I can't interrupt anything.Here's a minimal example that reproduces this:
Run this cell twice in a row.
lancekrogers commentedon Oct 27, 2016
This same issue happens for me in Unix as well word for word.
"When a subprocess is run from the notebook, if it gets stuck the kernel will get locked waiting for it. Selecting Kernel/Interrupt from the menu does not terminate the subprocess, but rather leaves the kernel in an unstable, "partially locked" state, where other cells do not execute. The only resolution is to restart the kernel."
nealmcb commentedon May 8, 2017
Thanks for the nice example of a pdb hang, wmayner. But sInce pdb doesn't run in a subprocess, I opened a separate issue for pdb: #10516
JulesGM commentedon Mar 14, 2018
Printing too much data, let's say accidentally printing a gigantic numpy array, can make the kernel completely unresponsive and impossible to to terminate
rajulah commentedon May 29, 2018
Has a solution been found for this issue yet? i just ran a machine learning model that took 14hr to complete and now my kernel is stuck and doesnt execute cells. if i restart, i have to run the model again for 14hrs. So is there any solution?
JulesGM commentedon May 29, 2018
haven't tried it, but this seems like it could help: http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/limit_output/readme.html
29 remaining items
jvschoen commentedon Aug 31, 2020
I run into this sometimes too... Here is a reproduceable example from jupyer lab:
LOAD DATA
Run Grid Search: THIS CANNOT BE INTERRUPTED
Is there any advice?
dawnset commentedon Oct 13, 2020
run into this problem three times this afternoon, reminds me of the good old days when i was still using urllib.
thought its on urllib, cause there is no response to my request.
I was working but coding, I have to find a solution but a answer. So I store every variable to local file.
really don't want to see that happen again and again.
Crispy13 commentedon Oct 20, 2020
I am facing the same issue when using tensorflow and gpu for training deep learning model.
matija2209 commentedon Nov 17, 2020
Run into this with time.sleep and requests
mbrad092 commentedon Dec 5, 2020
Also having this issue with time.sleep requests on Windows, but runs fine on Mac OS X
not-Ian commentedon Dec 22, 2020
Having this issue with ThreadPoolExecutor... Something like this:
Only way to interrupt is to restart kernel... very frustrating
TV4Fun commentedon Feb 2, 2021
This is still happening. I would suggest re-opening this issue. Seeing it in a NumPy-heavy tight neural network training loop on Windows 10.
Is there anything I need to upgrade?
Esesna commentedon Jun 6, 2021
Возникает такая же проблема, и самое интересное в случайных участках кода при использование B0 remote api для coppelia sim. При это если я использую Publisher и Subscriber
hamitaksln commentedon Nov 19, 2021
I found this solution to stop cell when I work with time sleep or requests:

thistlillo commentedon Mar 21, 2022
Are there any news on this issue? I am working remotely in a Kubernetes pod and, when this occurs, I am completely locked out of the machine. I cannot even open a shell.
MrMino commentedon Mar 21, 2022
@thistlillo your issue is most likely unrelated to this one. In any case, we would need more information than what you've provided, like: version of IPython and Python you're using, whether you are using Jupyter Notebook or Jupyter Lab, versions of those, etc. And, most importantly, a minimalized set of steps required to reproduce the issue.
If you can provide this info, please create a new issue and include it.
UmarZein commentedon Jun 7, 2023
I ran into this issue today on my linux laptop. Although I have not found a way to interrupt the kernel, I was able to save my variables by injecting a
pickle.dumpsusingpyrasite. Thanks to https://stackoverflow.com/a/59124617/18638036Shubhang9 commentedon Jul 6, 2023
Hey guys! I also had the same issue, but it was a silly mistake on my end.
Avoid using try without adding specific exceptions in your except block you are expecting your code to throw. A generic try looks like this -
It seems like this code would also catches your keyboard Interrupts/ kernel interrupts which registers as KeyboardInterrupt exception (only if execution is inside this try block) .
I thought it might help some unfortunate souls if I share it here.
ericdrosas87 commentedon Apr 4, 2025
Just tossing my 🎩 into the ring that I too am experiencing this issue
rajhlinux commentedon Nov 1, 2025
Its 2025... getting same error, endless cycle of Interrupts kernel dialog while on the children Jupyter notebook to teach adult "programmers" how to program.
Edit:
So need to update VS code and then restart... Jupyter (stuff used to teach kids how to program for "software engineers" 🤣) then doesn't throw the endless "Interrupts kernel dialog". Programmers will get dumb when things are taught via Jupyter, it's so unfortunate.