-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Restore detection of missing terminado package #5465
Restore detection of missing terminado package #5465
Conversation
Support for the command line disablement still isn't right (sigh). Will remove [WIP] once resolved. |
notebook/notebookapp.py
Outdated
@@ -300,7 +306,7 @@ def init_settings(self, jupyter_app, kernel_manager, contents_manager, | |||
allow_password_change=jupyter_app.allow_password_change, | |||
server_root_dir=root_dir, | |||
jinja2_env=env, | |||
terminals_available=False, # Set later if terminals are available | |||
terminals_available=terminals_available, |
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.
There are three related things, which I think might be getting a bit confused here:
a. The terminals_enabled
config option, which is True by default.
b. Whether terminado can be imported
c. Whether we are exposing terminals (i.e. enabled and importable)
Currently (before this PR), we use terminals_enabled
for a and terminals_available
for c (i.e. available to the user). In this PR,terminals_available
refers to b, and terminals_enabled
to c.
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.
Agreed - see latest commit.
notebook/notebookapp.py
Outdated
except ImportError as e: | ||
self.terminals_enabled = False |
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.
Modifying this still seems like it's inviting confusion, because what .terminals_enabled
means depends on the point at which you use it: before this, it means a config option, and after this it means whether the terminal machinery is used.
Can I suggest that we keep clearly separate terms for the three things we might want to know, e.g. terminals_available
, terminals_enabled
and terminals_in_use
?
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.
+1, although I believe terminado_available
as an indication of the package's presence is more clear than terminals_available
if that's okay.
I also think it's important to issue the warning message when terminals are enabled but the terminado is not present even though we know that answer prior to init_terminals
. I've retained that try-catch in case there might be other initialization failures down the road.
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.
No problem - I wasn't tied to those specific names, just keen to distinguish the concepts.
Now terminals_available
on the webapp is the equivalent of terminals_in_use
on the Jupyter app class. It's possibly worth aligning those, but I don't think it's a big deal either.
notebook/notebookapp.py
Outdated
if term_mgr.terminals: | ||
return # Terminals still running | ||
if not self.terminals_in_use: | ||
return |
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.
This doesn't look quite right. This method is to shut down the server after a certain time with no kernels/terminals. Terminals not in use means no terminals running, but this early return prevents it from ever shutting down.
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.
😄 Looks like we could do with another pass at naming, as you alluded to in another comment. I was coming to same conclusion about terminals_in_use
yesterday (while doing yard work). I think a switch (alignment) to terminals_available
might just be the best name:
a. terminado_available
= Terminado package is installed
b. terminals_enabled
= User has condoned the use of terminals (independent of terminado's presence)
c. terminals_available
= User has condoned the use of terminals and terminado is installed
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.
To be clear, I think there's an actual logic bug here, regardless of which name we're using. ;-)
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.
You're absolutely correct. Thank you for spotting that.
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. I think this is in good shape now. :-)
Other than my latest comment about shutting down on a timeout, I think this looks good now. |
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!
Because the change to add culling of terminals derived from terminado's terminal manager in a local class, it inadvertently broke Notebook server's functionality to tolerate a missing terminado package. These changes restore that behavior.