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

Stop / unload / cleanup hook for a server extension #241

Closed
jtpio opened this issue Jun 2, 2020 · 1 comment · Fixed by #526
Closed

Stop / unload / cleanup hook for a server extension #241

jtpio opened this issue Jun 2, 2020 · 1 comment · Fixed by #526

Comments

@jtpio
Copy link
Member

jtpio commented Jun 2, 2020

Is there currently a way for a server extension (that would run alongside other server extensions) to provide a stop / unload / cleanup hook, that would be called when the main server app is terminated (potentially in the stop method)?

It looks like one way to achieve this would be for an ExtensionApp to define the ExtensionApp.stop() method. Although this might be dedicated to extension apps started as standalone extensions?

As an example use case, a server extension could allocate extra resources that would need to be cleaned up when the app is stopped.

For example an ExtensionApp might want to instantiate a separate MappingKernelManager to keep a set of kernels isolated from the default kernel manager (this is currently explored in voila-dashboards/voila#41 and also discussed in #235).
Having a separate kernel manager would require calling the shutdown_all method to make sure the kernel processes are terminated.

@oliver-sanders
Copy link
Contributor

Looks like the ExtensionApp now has a stop method, however, it is for shutting down the server from the extension rather than shutting down the extension from the server:

def stop(self):
"""Stop the underlying Jupyter server.
"""
self.serverapp.stop()
self.serverapp.clear_instance()

oliver-sanders added a commit to oliver-sanders/jupyter_server that referenced this issue May 21, 2021
* closes jupyter-server#241
* call a stop_extension method on server shutdown if present
oliver-sanders added a commit to oliver-sanders/jupyter_server that referenced this issue May 21, 2021
* closes jupyter-server#241
* call a stop_extension method on server shutdown if present
oliver-sanders added a commit to oliver-sanders/jupyter_server that referenced this issue May 21, 2021
* closes jupyter-server#241
* call a stop_extension method on server shutdown if present
oliver-sanders added a commit to oliver-sanders/jupyter_server that referenced this issue Jun 11, 2021
* closes jupyter-server#241
* call a stop_extension method on server shutdown if present
oliver-sanders added a commit to oliver-sanders/jupyter_server that referenced this issue Jun 30, 2021
* closes jupyter-server#241
* call a stop_extension method on server shutdown if present
Zsailer pushed a commit that referenced this issue Jul 8, 2021
* stop hook for extensions

* closes #241
* call a stop_extension method on server shutdown if present

* fix typo

* make extension stop hooks async

* extension stop hook tests

* extension stop hooks feedback

* run_sync

* extension stop hooks extension_apps property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants