Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Dec 18, 2023
1 parent bce8593 commit 1079a67
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jupyter_client/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from . import __version__
from .kernelspec import NATIVE_KERNEL_NAME, KernelSpecManager
from .manager import AsyncKernelManager
from .utils import get_event_loop


class KernelApp(JupyterApp):
Expand All @@ -33,7 +34,7 @@ class KernelApp(JupyterApp):
config=True
)

def initialize(self, argv: t.Union[str, t.Sequence[str], None] = None) -> None:
async def initialize(self, argv: t.Union[str, t.Sequence[str], None] = None) -> None:
"""Initialize the application."""
super().initialize(argv)

Expand Down Expand Up @@ -90,7 +91,7 @@ async def start(self):

# TODO: move these to JupyterApp.
@classmethod
async def _inner_launch_instance(cls, argv=None, **kwargs):
async def _async_launch_instance(cls, argv=None, **kwargs):
"""Launch the instance from inside an event loop."""
app = cls.instance(**kwargs)
# Allow there to be a synchronous or asynchronous init method.
Expand All @@ -104,9 +105,9 @@ def launch_instance(cls, argv=None, **kwargs):
If a global instance already exists, this reinitializes and starts it
"""
# TODO: if there is a global loop running, use that.
# TODO: handle windows and loop_factory.
asyncio.run(cls._inner_launch_instance(argv, **kwargs))
loop = get_event_loop()
coro = cls._async_launch_instance(argv, **kwargs)
loop.run_until_complete(coro)


main = KernelApp.launch_instance

0 comments on commit 1079a67

Please sign in to comment.