jupyterhub / simpervisor

Simple Python3 Supervisor library
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Simpervisor overrides the existing signal handlers #38

Open mahendrapaipuri opened 1 year ago

mahendrapaipuri commented 1 year ago

Proposed change

Simpervisor defines its own atexit implementation to register signal handlers. The issue is that sets its own signal handler for SIGINT and SIGTERM "potentially" overriding any existing handlers.

An example use case when we use jupyter-server-proxy to start managed applications. It uses simpervisor behind the hood to supervise the proxy application. By the time simpervisor registers signal handlers, there are already existing handlers for sigint and sigterm by ServerApp. So, simpervisor overrides these handlers registered by ServerApp. This can be easily verified by running a JupyterLab instance with jupyter-server-proxy installed. Start a simple web server from JupyterLab using jupyter-server-proxy and then doing a Ctrl+C on the terminal that is running JupyterLab will shutdown the Lab immediately without the usual prompt of shutdown confirmation.

The signal handlers of the ServerApp cleans up the kernels and extensions before terminating itself. So, we lose this cleaning up tasks due to simpervisor overriding the handlers. We noticed on our JupyterHub deployment on our HPC platform that this can have a undesirable side effects of proxy processes lingering around even after ServerApp is killed.

Who would use this feature?

Anyone who is using simpervisor along with Jupyter ServerApp.

(Optional): Suggest a solution

Ensure that we register the existing signal handlers in _handlers list, if they exist.

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
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! :wave:
Welcome to the Jupyter community! :tada:

consideRatio commented 1 year ago

Wieee what a great writeup!!! Thank you @mahendrapaipuri for writing this up so clearly!