jupyter-server / jupyter_server

The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.
https://jupyter-server.readthedocs.io
BSD 3-Clause "New" or "Revised" License
485 stars 294 forks source link

Why can't the terminal be interrupted? #668

Open icankeep opened 2 years ago

icankeep commented 2 years ago

When I execute tail -f jupyter.log in terminal, it cannot be interrupted by ctrl+c

image

davidbrochart commented 2 years ago

I just tried with Jupyter Lab, and ctrl-c works for me. Can you provide more information about your environment?

icankeep commented 2 years ago

The bash process also cannot be killed when tail -f jupyter.log is executed

kill -1 <bash_pid>
icankeep commented 2 years ago

But I do the same by connecting to the container via ssh and can interrupt the process with ctrl+c

icankeep commented 2 years ago

I just tried with Jupyter Lab, and ctrl-c works for me. Can you provide more information about your environment?

yeah, It's so confusing, I can use it on my mac and it can be interrupted. what information do I need to provide?

davidbrochart commented 2 years ago
icankeep commented 2 years ago

os: Linux CentOS7 jupyter labhub jupyterlab version: 3.1.18

pip freeze

absl-py==1.0.0
aiohttp==3.8.1
aiosignal==1.2.0
alembic==1.7.4
altair==4.1.0
ansiwrap==0.8.4
antlr4-python3-runtime==4.7
anyio==3.3.4
argon2-cffi==21.1.0
astor==0.8.1
astroid==2.6.6
astropy==4.1
async-generator==1.10
async-timeout==4.0.1
asynctest==0.13.0
attrs==21.2.0
autopep8==1.5.7
Babel==2.9.1
backcall==0.2.0
beautifulsoup4==4.7.1
black==21.11b1
bleach==4.1.0
bokeh==2.0.0
branca==0.4.2
brotlipy==0.7.0
cachetools==4.2.4
certifi==2021.10.8
certipy==0.1.3
cffi==1.15.0
chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1610093477613/work
charset-normalizer==2.0.7
cleanlab==0.1.1
click==7.1.2
cloudpickle==0.8.1
cmdstanpy==0.9.68
colorama==0.4.4
confuse==1.6.0
contextvars==2.4
convertdate==2.1.2
crypto==1.4.1
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1634230300355/work
cssselect==1.1.0
cssutils==2.3.0
cycler==0.11.0
Cython==0.29.24
dask==1.1.5
dataclasses==0.8
decorator==5.1.0
defusedxml==0.7.1
deprecation==2.1.0
descartes==1.1.0
dill==0.2.9
docopt==0.6.2
dowhy==0.6
dx==0.2.4
econml==0.12.0
entrypoints==0.3
ephem==3.7.7.1
et-xmlfile==1.1.0
faiss==0.1
flake8==3.9.2
folium==0.11.0
frozenlist==1.2.0
future==0.18.2
gast==0.2.2
gensim==3.7.3
gitdb==4.0.9
GitPython==3.1.20
google-pasta==0.2.0
graphviz==0.13.2
greenlet==1.1.2
grpcio==1.42.0
h3==3.6.1
h5py==2.9.0
hdfs==2.5.8
hdfs3==0.3.1
holidays==0.10.2
hope==3.5.12
htmlmin==0.1.12
hyperopt==0.2.5
idna==3.3
idna-ssl==1.1.0
ImageHash==4.2.1
immutables==0.16
importlib-metadata==4.8.1
importlib-resources==5.4.0
ipyaggrid2==0.2.4
ipykernel==5.5.6
ipython==7.16.1
ipython-genutils==0.2.0
ipywidgets==7.6.3
isort==5.10.1
jdcal==1.4.1
jedi==0.17.2
jieba==0.42.1
Jinja2==3.0.2
joblib==1.1.0
json5==0.9.6
jsonschema==4.0.0
jupyter-bokeh==3.0.0
jupyter-client==7.0.6
jupyter-core==4.9.1
jupyter-lsp==1.5.0
jupyter-packaging==0.10.6
jupyter-resource-usage==0.6.0
jupyter-server==1.11.2
jupyter-server-mathjax==0.2.3
jupyter-server-proxy==1.2.0
jupyter-telemetry==0.1.0
jupyterhub==1.3.0
jupyterlab==3.1.18
jupyterlab-git==0.33.0
jupyterlab-header==0.1.1
jupyterlab-lsp==3.8.1
jupyterlab-moses==3.1.0
jupyterlab-mtjupyter==3.1.3
jupyterlab-mtjupyter-menu==0.1.9
jupyterlab-mtjupyter-mimerenderer==3.0.1
jupyterlab-pygments==0.1.2
jupyterlab-server==2.8.2
jupyterlab-system-monitor==0.8.0
jupyterlab-topbar==0.6.1
jupyterlab-widgets==1.0.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
kiwisolver==1.3.1
kmsagent==2.0.0
koalas==1.8.1
korean-lunar-calendar==0.2.1
kylinpy==2.8.4
lazy-object-proxy==1.6.0
lightgbm==2.2.3
llvmlite==0.32.1
LunarCalendar==0.0.9
lxml==4.6.4
Mako==1.1.5
Markdown==3.3.6
MarkupSafe==2.0.1
matplotlib==3.2.2
mccabe==0.6.1
missingno==0.5.0
mistune==0.8.4
mlp-terminado-test===0.12.1.test7
mmh3==2.5.1
mmlspark @ https://s3plus.vip.sankuai.com/v1/mss_da3b6422d897465dbf3b78c154373d14/mtjupyter-upload/system/mmlspark-0.18.1-py2.py3-none-any.whl
mpmath==1.2.1
msgpack==0.6.2
mssapi==1.0
mtjupyter-singleuser==2.5.4.4
mtjupyter-utils==0.0.2.16
mtjupyterlab-code-snippets==2.0.5
mtthrift==1.1.3
mtthrift-client==1.0.5
multidict==5.2.0
mypy-extensions==0.4.3
Naked==0.1.31
nbclassic==0.3.4
nbclient==0.5.4
nbconvert==6.0.7
nbdime @ https://s3plus.sankuai.com/v1/mss_ba2c968650114cf3a31ec87b5193ea00/jupyter-system/python-dev/nbdime-3.1.1.dev0.tar.gz
nbformat==5.1.3
nest-asyncio==1.5.1
networkx==2.4
notebook==6.2.0
noticemagics==0.1.1
numba==0.42.0
numexpr==2.6.9
numpy==1.18.0
oauthlib==3.1.1
opencv-contrib-python-nonfree-headless==4.1.1.1
openpyxl==2.6.4
opt-einsum==3.3.0
ortools==7.5.7466
packaging==21.2
pamela==1.0.0
pandas==1.0.4
pandas-profiling==2.8.0
pandocfilters==1.5.0
papermill==2.3.3
parso==0.7.1
pathspec==0.9.0
patsy==0.5.2
pexpect==4.8.0
phik==0.12.0
phxmllib==0.0.3
phxutils==2.0.4
pickleshare==0.7.5
Pillow==8.4.0
platformdirs==2.4.0
plotly==4.14.3
plotly-geo==1.0.0
pluggy==1.0.0
ply==3.11
premailer==3.10.0
prettytable==2.4.0
prometheus-client==0.12.0
prompt-toolkit==3.0.22
prophet==1.0
protobuf==3.11.2
psutil==5.8.0
ptyprocess==0.7.0
pyaml==21.10.1
pyarrow==0.16.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1593275161868/work
pycrypto==2.6.1
pycryptodome==3.11.0
pydocstyle==6.1.1
pydot==1.4.2
pyecharts==1.8.1
pygeohash==1.2.0
Pygments==2.10.0
pykerberos @ file:///home/conda/feedstock_root/build_artifacts/pykerberos_1621070883986/work
pylift==0.1.5
pylint==2.9.6
PyMySQL==0.9.3
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1633192417276/work
pyparsing==2.4.7
pyrsistent==0.18.0
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1610291458349/work
pysparkfix==0.0.1
pystan==2.18.0.0
python-dateutil==2.8.0
python-json-logger==2.0.2
python-Levenshtein==0.12.0
python-lsp-jsonrpc==1.0.0
python-lsp-server==1.2.4
pytz==2017.3
PyWavelets==1.1.1
PyYAML==6.0
pyzmq==22.3.0
regex==2021.11.10
requests==2.26.0
requests-kerberos==0.11.0
retrying==1.3.3
rope==0.21.1
ruamel.yaml==0.17.17
ruamel.yaml.clib==0.2.6
scikit-image==0.14.5
scikit-learn==0.24.2
scikit-optimize==0.9.0
scikit-uplift==0.4.0
scipy==1.5.2
seaborn==0.9.1
Send2Trash==1.8.0
setuptools-git==1.2
shap==0.39.0
Shapely==1.7.0
shellescape==3.8.1
simpervisor==0.4
simplejson==3.17.6
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
slicer==0.0.7
smart-open==5.2.1
smmap==5.0.0
sniffio==1.2.0
snowballstemmer==2.2.0
snownlp==0.12.3
soupsieve==2.3.1
sparkmagics==2.0.8
sparse==0.7.0
SQLAlchemy==1.3.24
sqlalchemy-zebra==0.0.3
statsmodels==0.12.2
sympy==1.4
talosmagics==0.0.5
tangled-up-in-unicode==0.2.0
tenacity==8.0.1
tensorboard==1.15.0
tensorflow-estimator==1.15.1
tensorflow-gpu==1.15.0
termcolor==1.1.0
terminado==0.12.1
testpath==0.5.0
textwrap3==0.9.2
tfmagics==0.1.0
threadpoolctl==3.0.0
thriftpy2==0.4.14
toml==0.10.2
tomli==1.2.2
tomlkit==0.7.2
toolz==0.11.2
torch==1.6.0
torchvision==0.7.0
tornado==6.1
tqdm==4.43.0
traitlets==4.3.3
typed-ast==1.4.3
typing-extensions==3.10.0.2
ujson==4.2.0
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1632350318291/work
vincent==0.4.4
visions==0.4.4
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.2.1
Werkzeug==2.0.2
widgetsnbextension==3.5.2
wrapt==1.12.1
xgboost==0.80
xlrd==1.2.0
xlwt==1.3.0
yapf==0.31.0
yarl==1.7.2
yattag==1.11.2
ZebraPyApi==0.0.5.8
zipp==3.6.0
davidbrochart commented 2 years ago

Thanks, what's your Python version?

icankeep commented 2 years ago
UID         PID   PPID  C STIME TTY          TIME CMD
xxx    5066   3852  0 16:32 ?        00:00:00 bash -l
xxx    5088   5066  0 16:32 ?        00:00:00 tail -f logs/mtjupyter.log

Execute the following command, the subprocess of bash cannot be killed

kill -1 5066
UID         PID   PPID  C STIME TTY          TIME CMD
xxx    5066   3852  0 16:32 ?        00:00:00 [bash] <defunct>
xxx    5088      1  0 16:32 ?        00:00:00 tail -f logs/mtjupyter.log
icankeep commented 2 years ago

Thanks, what's your Python version?

Python 3.6.13

davidbrochart commented 2 years ago

faiss==0.1 doesn't seem to exist: https://pypi.org/project/faiss/#history

icankeep commented 2 years ago

I found the reason.

reproduce step:

  1. bash start_jupyter.sh
#!/bin/bash
export PATH=/opt/conda/bin:$PATH
source activate python3.6
nohup jupyter lab --ip=0.0.0.0 --port=80 --allow-root > jupyter.log 2>&1 &
  1. Open a terminal and execute the following command
    tail -f jupyter.log

image

icankeep commented 2 years ago

thank you for your reply, I will close this issue

dlqqq commented 1 year ago

Can we re-open this issue? I'm experiencing this intermittently as well. After the SIGINT fails to kill the server process, I sometimes see the following output printed to the terminal. I think this is highly relevant to this issue:

Exception in thread Thread-1 (_confirm_exit):
Traceback (most recent call last):
  File "/home/dlq/anaconda3/envs/jai/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/dlq/anaconda3/envs/jai/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dlq/anaconda3/envs/jai/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2208, in _confirm_exit
    line = sys.stdin.readline()
OSError: [Errno 5] Input/output error
ellisonbg commented 1 year ago

I am also experiencing this as of late (couldn't kill the server using SIGINT).

davidbrochart commented 1 year ago

Does it happen when enabling collaborative mode? I can see a possibility for it to happen because of asyncio tasks not being cancelled on exit (in jupyter-collaboration and ypy-websocket).

dlqqq commented 1 year ago

I managed to reproduce the issue. For some reason, whenever I start jupyter server from a package.json script (e.g. yarn run dev), this issue always happens, and the newly-spawned server process cannot be interrupted. But typing the body of the script into the terminal spawns the server but allows it to be interrupted. I think the workaround for now is to just avoid starting Jupyter Server from package.json scripts and invoke it manually instead.

davidbrochart commented 1 year ago

Thanks for the feedback @dlqqq. Probably yarn doesn't forward SIGINT to the spawned process.