Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter-server-proxy not 'proxying/passing' signal handlers to proxied apps. #283

Open
chimmy-changa opened this issue Jul 13, 2021 · 1 comment
Labels

Comments

@chimmy-changa
Copy link

chimmy-changa commented Jul 13, 2021

Bug description

Signal handlers registered on the proxied app are not passed from jupyter to the proxied app when the jupyter process is interrupted [Ctrl + C]

Expected behaviour

When the jupyter process is interrupted using Ctrl + C, this signal ie. SIGINT, should be passed on to the child processes of jupyter such as the proxied apps created by the jupyter server proxy.

Actual behaviour

When jupyter process is interrupted using Ctrl +C, SIGINT is only passed to the root jupyter process, which kills all the proxied apps created by jupyter server proxy.

The signal handlers registered in the proxied apps are not able to 'catch' the signal because the root jupyter process consumes the interrupt without passing it to the proxied apps created by jupyter server proxy.

How to reproduce

  1. Create a python package which runs a simple aiohttp server.
  2. Register signal handlers to trap termination signals. This is to perform some shutdown-background-tasks and then close.
  3. In setup.py of the python package add the entrypoint jupyter_serverproxy_servers and point it to the function which starts the server.
  4. Start jupyter notebook and launch the aiohttp server within the jupyter notebook.
  5. Send interrupt signal to the shell by pressing Ctrl + C.

After performing step 5 above, you can see that the interrupt signal was not passed to the proxied app (here its aiohttp server) and thereby leading to runtime errors in the shell:

  File "/usr/lib/python3.7/asyncio/base_events.py", line 582, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

This error shows up because, after catching the interrupt signal, I perform some cleanup work and then shutdown the server. That cleanup work is asynchronously finished using the function loop.run_until_complete() provided by asycio package

Your personal set up

Running from a local virtual env which was created using the below command:

python -m venv .venv
  • OS:
    Debian GNU/Linux 10 (buster) x86_64

  • Version(s):
    python: 3.7

  • Jupyter versions:
    jupyter core : 4.7.1
    jupyter-notebook : 6.4.0
    qtconsole : 5.1.1
    ipython : 7.25.0
    ipykernel : 6.0.1
    jupyter client : 6.1.12
    jupyter lab : not installed
    nbconvert : 6.1.0
    ipywidgets : 7.6.3
    nbformat : 5.1.3
    traitlets : 5.0.5

  • Full environment
# paste output of `pip freeze` or `conda list` here
aiohttp==3.7.4.post0
aiohttp-devtools==0.13.1
aioresponses==0.7.2
anyio==3.2.1
argon2-cffi==20.1.0
async-generator==1.10
async-timeout==3.0.1
attrs==21.2.0
backcall==0.2.0
bleach==3.3.0
certifi==2021.5.30
cffi==1.14.6
chardet==4.0.0
click==8.0.1
coverage==5.5
debugpy==1.3.0
decorator==5.0.9
defusedxml==0.7.1
devtools==0.6.1
entrypoints==0.3
idna==2.10
importlib-metadata==3.10.1
iniconfig==1.1.1
ipykernel==6.0.1
ipython==7.25.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
jedi==0.18.0
Jinja2==3.0.1
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.12
jupyter-console==6.4.0
jupyter-core==4.7.1
# Custom python package which runs the aiohttp server
jupyter-xyz-proxy==0.2.0
jupyter-server==1.9.0
jupyter-server-proxy==3.1.0
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
MarkupSafe==2.0.1
matplotlib-inline==0.1.2
mistune==0.8.4
multidict==5.1.0
nbclient==0.5.3
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
notebook==6.4.0
packaging==21.0
pandocfilters==1.4.3
parso==0.8.2
pexpect==4.8.0
pickleshare==0.7.5
pkg-resources==0.0.0
pluggy==0.13.1
prometheus-client==0.11.0
prompt-toolkit==3.0.19
psutil==5.8.0
ptyprocess==0.7.0
py==1.10.0
pycparser==2.20
Pygments==2.9.0
pyparsing==2.4.7
pyrsistent==0.18.0
pytest==6.2.4
pytest-aiohttp==0.3.0
pytest-cov==2.12.1
pytest-dependency==0.5.1
pytest-env==0.6.2
pytest-mock==3.6.1
python-dateutil==2.8.1
pyzmq==22.1.0
qtconsole==5.1.1
QtPy==1.9.0
requests==2.25.1
requests-unixsocket==0.2.0
Send2Trash==1.7.1
simpervisor==0.4
six==1.16.0
sniffio==1.2.0
terminado==0.10.1
testpath==0.5.0
toml==0.10.2
tornado==6.1
traitlets==5.0.5
typing-extensions==3.10.0.0
urllib3==1.26.6
watchgod==0.7
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.1.0
widgetsnbextension==3.5.1
yarl==1.6.3
zipp==3.5.0
@welcome
Copy link

welcome bot commented Jul 13, 2021

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant