Skip to content

Commit

Permalink
parallelize async extension start
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed Feb 13, 2025
1 parent 8a31ea3 commit 1775c56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions jupyter_server/extension/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ def load(self, serverapp):
loader = self._get_loader()
return loader(serverapp)

def start(self, serverapp):
async def start(self, serverapp):
"""Call's the extensions 'start' hook where it can
start (possibly async) tasks _after_ the event loop is running.
"""
starter = self._get_starter()
return starter(serverapp)
return await starter(serverapp)


class ExtensionPackage(LoggingConfigurable):
Expand Down Expand Up @@ -247,10 +247,10 @@ def load_point(self, point_name, serverapp):
point = self.extension_points[point_name]
return point.load(serverapp)

def start_point(self, point_name, serverapp):
async def start_point(self, point_name, serverapp):
"""Load an extension point."""
point = self.extension_points[point_name]
return point.start(serverapp)
return await point.start(serverapp)

def link_all_points(self, serverapp):
"""Link all extension points."""
Expand Down Expand Up @@ -447,8 +447,7 @@ async def start_all_extensions(self):
"""Start all enabled extensions."""
# Sort the extension names to enforce deterministic loading
# order.
for name in self.sorted_extensions:
await self.start_extension(name)
await multi([self.start_extension(name) for name in self.sorted_extensions.keys()])

async def stop_all_extensions(self):
"""Call the shutdown hooks in all extensions."""
Expand Down
3 changes: 3 additions & 0 deletions tests/extension/mockextensions/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class MockExtensionApp(ExtensionAppJinjaMixin, ExtensionApp):
}
}

async def _start_jupyter_server_extension(self, serverapp):
self.started = True

@staticmethod
def get_extension_package():
return "tests.extension.mockextensions"
Expand Down

0 comments on commit 1775c56

Please sign in to comment.