Skip to content

Commit

Permalink
add current_activity hook for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed Dec 30, 2021
1 parent c6f1b93 commit 596a554
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion jupyter_server/extension/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class ExtensionHandlerMixin:
other extensions.
"""

def initialize(self, name):
def initialize(self, name, **kwargs):
self.name = name
super().initialize(**kwargs)

@property
def extensionapp(self):
Expand Down
3 changes: 2 additions & 1 deletion jupyter_server/extension/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ async def stop_all_extensions(self):
)

def any_activity(self):
"""Check for any activity currently happening across all extension applications."""
for name, app in sorted(dict(self.extension_apps).items()):
if app.activity:
if app.current_activity():
return True
5 changes: 0 additions & 5 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,11 +2090,6 @@ def shutdown_no_activity(self):
if self.extension_manager.any_activity:
return

if self.terminals_available:
term_mgr = self.web_app.settings["terminal_manager"]
if term_mgr.terminals:
return # Terminals still running

seconds_since_active = (utcnow() - self.web_app.last_activity()).total_seconds()
self.log.debug("No activity for %d seconds.", seconds_since_active)
if seconds_since_active > self.shutdown_no_activity_timeout:
Expand Down

0 comments on commit 596a554

Please sign in to comment.