-
Notifications
You must be signed in to change notification settings - Fork 305
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
Add async start hook to ExtensionApp API #1417
base: main
Are you sure you want to change the base?
Conversation
cc @vidartf and @afshin, since we discussed this a bit on the server call today. I've added documentation and made it possible to write one of these hooks for "classic" server extensions, i.e. extensions that don't inherit from the The function must be named |
Downstream test failures appear to be unrelated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Zsailer
I have some questions about this:
- why not using
start_extension
to get an easier to understand APIstart/stop_extension
? - if not renaming to
start_extension
, we should not prefix the class method with_
(akaExtensionApp._start_jupyter_server_extension
) as the convention implies that those have visibility protected and that does not fit the need for them to be public (to be accessed by the extension manager). - I understand why you would add support for the classic extension. But in that case, I feel that we should also allow the
stop_extension
hook as it will surely be needed to clean started resources.
Hey @fcollonval 👋 Thanks for looking at this. First, let me acknowledge the obvious... naming is hard.
I originally used this naming pattern, but in the last Jupyter Server meeting, folks asked if we could make this API available for "simple" server extension, i.e. one's that don't inherit from ExtensionApp. The pattern set for classic extension is to use I'm fine with have
Hm, I understand what you mean, but this is a slightly odd/edge case. The The extension manager is a special case. Yes, technically it's breaking the "public visibility within a class" convention, but it's a special type of "public" here. It must change if the We followed this same logic when renaming the
Sure. I don't think it's strictly necessary for this PR to be reviewed/merged. I'm happy to add it here, but there are many other cases where you need an async start action without leaving lingering resources around that need cleanup. |
This is enabled in the current API, and is used by jupyter-lsp, using the function-based mechanism: def load_jupyter_server_extension(nbapp):
if hasattr(nbapp, "io_loop"):
io_loop = nbapp.io_loop
else:
# handle jupyter_server 1.x
io_loop = ioloop.IOLoop.current()
io_loop.call_later(0, initialize, nbapp, virtual_documents_uri)
async def initialize(nbapp, virtual_documents_uri):
await #... yadda yadda The shortcoming is this spews a lot of output (especially with We added this because people complained about how long a server took to start up in a JupyterHub setting. Blocking the URL print would feel perceptually worse, but in the end would feel better. |
Thanks @Zsailer for your detailed answer. The arguments with the naming make sense. Indeed naming is always a high source of debates 😅 Regarding adding |
Fixes #1203 and #1329