@@ -283,7 +283,7 @@ async def _async__launch_kernel(
283
283
"""
284
284
return launch_kernel (kernel_cmd , ** kw )
285
285
286
- _launch_kernel = _async__launch_kernel
286
+ _launch_kernel = run_sync ( _async__launch_kernel )
287
287
288
288
# Control socket used for polite kernel shutdown
289
289
@@ -383,7 +383,7 @@ async def _async_start_kernel(self, **kw):
383
383
self .kernel = await self ._async__launch_kernel (kernel_cmd , ** kw )
384
384
self .post_start_kernel (** kw )
385
385
386
- start_kernel = _async_start_kernel
386
+ start_kernel = run_sync ( _async_start_kernel )
387
387
388
388
def request_shutdown (
389
389
self ,
@@ -433,7 +433,7 @@ async def _async_finish_shutdown(
433
433
self .kernel .wait ()
434
434
self .kernel = None
435
435
436
- finish_shutdown = _async_finish_shutdown
436
+ finish_shutdown = run_sync ( _async_finish_shutdown )
437
437
438
438
def cleanup_resources (
439
439
self ,
@@ -517,7 +517,7 @@ async def _async_shutdown_kernel(
517
517
else :
518
518
self .cleanup_resources (restart = restart )
519
519
520
- shutdown_kernel = _async_shutdown_kernel
520
+ shutdown_kernel = run_sync ( _async_shutdown_kernel )
521
521
522
522
async def _async_restart_kernel (
523
523
self ,
@@ -563,7 +563,7 @@ async def _async_restart_kernel(
563
563
self ._launch_args .update (kw )
564
564
await self ._async_start_kernel (** self ._launch_args )
565
565
566
- restart_kernel = _async_restart_kernel
566
+ restart_kernel = run_sync ( _async_restart_kernel )
567
567
568
568
@property
569
569
def has_kernel (self ) -> bool :
@@ -600,7 +600,7 @@ async def _async__send_kernel_sigterm(self) -> None:
600
600
if e .errno != ESRCH :
601
601
raise
602
602
603
- _send_kernel_sigterm = _async__send_kernel_sigterm
603
+ _send_kernel_sigterm = run_sync ( _async__send_kernel_sigterm )
604
604
605
605
async def _async__kill_kernel (self ) -> None :
606
606
"""Kill the running kernel.
@@ -641,7 +641,7 @@ async def _async__kill_kernel(self) -> None:
641
641
self .kernel .wait ()
642
642
self .kernel = None
643
643
644
- _kill_kernel = _async__kill_kernel
644
+ _kill_kernel = run_sync ( _async__kill_kernel )
645
645
646
646
async def _async_interrupt_kernel (self ) -> None :
647
647
"""Interrupts the kernel by sending it a signal.
@@ -666,7 +666,7 @@ async def _async_interrupt_kernel(self) -> None:
666
666
else :
667
667
raise RuntimeError ("Cannot interrupt kernel. No kernel is running!" )
668
668
669
- interrupt_kernel = _async_interrupt_kernel
669
+ interrupt_kernel = run_sync ( _async_interrupt_kernel )
670
670
671
671
async def _async_signal_kernel (
672
672
self ,
@@ -691,7 +691,7 @@ async def _async_signal_kernel(
691
691
else :
692
692
raise RuntimeError ("Cannot signal kernel. No kernel is running!" )
693
693
694
- signal_kernel = _async_signal_kernel
694
+ signal_kernel = run_sync ( _async_signal_kernel )
695
695
696
696
async def _async_is_alive (self ) -> bool :
697
697
"""Is the kernel process still running?"""
@@ -704,7 +704,7 @@ async def _async_is_alive(self) -> bool:
704
704
# we don't have a kernel
705
705
return False
706
706
707
- is_alive = _async_is_alive
707
+ is_alive = run_sync ( _async_is_alive )
708
708
709
709
async def _async_wait (
710
710
self ,
@@ -718,23 +718,22 @@ async def _async_wait(
718
718
await asyncio .sleep (pollinterval )
719
719
720
720
721
- class BlockingKernelManager (KernelManager ):
722
- _launch_kernel = run_sync (KernelManager ._launch_kernel )
723
- start_kernel = run_sync (KernelManager .start_kernel )
724
- finish_shutdown = run_sync (KernelManager .finish_shutdown )
725
- shutdown_kernel = run_sync (KernelManager .shutdown_kernel )
726
- restart_kernel = run_sync (KernelManager .restart_kernel )
727
- _send_kernel_sigterm = run_sync (KernelManager ._send_kernel_sigterm )
728
- _kill_kernel = run_sync (KernelManager ._kill_kernel )
729
- interrupt_kernel = run_sync (KernelManager .interrupt_kernel )
730
- signal_kernel = run_sync (KernelManager .signal_kernel )
731
- is_alive = run_sync (KernelManager .is_alive )
732
-
733
721
class AsyncKernelManager (KernelManager ):
734
722
# the class to create with our `client` method
735
723
client_class : DottedObjectName = DottedObjectName ('jupyter_client.asynchronous.AsyncKernelClient' )
736
724
client_factory : Type = Type (klass = 'jupyter_client.asynchronous.AsyncKernelClient' )
737
725
726
+ _launch_kernel = KernelManager ._async__launch_kernel
727
+ start_kernel = KernelManager ._async_start_kernel
728
+ finish_shutdown = KernelManager ._async_finish_shutdown
729
+ shutdown_kernel = KernelManager ._async_shutdown_kernel
730
+ restart_kernel = KernelManager ._async_restart_kernel
731
+ _send_kernel_sigterm = KernelManager ._async__send_kernel_sigterm
732
+ _kill_kernel = KernelManager ._async__kill_kernel
733
+ interrupt_kernel = KernelManager ._async_interrupt_kernel
734
+ signal_kernel = KernelManager ._async_signal_kernel
735
+ is_alive = KernelManager ._async_is_alive
736
+
738
737
739
738
KernelManagerABC .register (KernelManager )
740
739
@@ -743,9 +742,9 @@ def start_new_kernel(
743
742
startup_timeout : float = 60 ,
744
743
kernel_name : str = 'python' ,
745
744
** kwargs
746
- ) -> t .Tuple [BlockingKernelManager , KernelClient ]:
745
+ ) -> t .Tuple [KernelManager , KernelClient ]:
747
746
"""Start a new kernel, and return its Manager and Client"""
748
- km = BlockingKernelManager (kernel_name = kernel_name )
747
+ km = KernelManager (kernel_name = kernel_name )
749
748
km .start_kernel (** kwargs )
750
749
kc = km .client ()
751
750
kc .start_channels ()
0 commit comments