1515from enum import Enum
1616
1717import zmq
18- from jupyter_events import EventLogger # type: ignore[import]
1918from traitlets import Any
2019from traitlets import Bool
2120from traitlets import default
3332from .provisioning import KernelProvisionerBase
3433from .provisioning import KernelProvisionerFactory as KPF
3534from .utils import run_sync
36- from jupyter_client import DEFAULT_EVENTS_SCHEMA_PATH
37- from jupyter_client import JUPYTER_CLIENT_EVENTS_URI
3835from jupyter_client import KernelClient
3936from jupyter_client import kernelspec
4037
@@ -94,27 +91,6 @@ class KernelManager(ConnectionFileMixin):
9491 This version starts kernels with Popen.
9592 """
9693
97- event_schema_id = JUPYTER_CLIENT_EVENTS_URI + "/kernel_manager/v1"
98- event_logger = Instance (EventLogger ).tag (config = True )
99-
100- @default ("event_logger" )
101- def _default_event_logger (self ):
102- if self .parent and hasattr (self .parent , "event_logger" ):
103- return self .parent .event_logger
104- else :
105- # If parent does not have an event logger, create one.
106- logger = EventLogger ()
107- schema_path = DEFAULT_EVENTS_SCHEMA_PATH / "kernel_manager" / "v1.yaml"
108- logger .register_event_schema (schema_path )
109- return logger
110-
111- def _emit (self , * , action : str ) -> None :
112- """Emit event using the core event schema from Jupyter Server's Contents Manager."""
113- self .event_logger .emit (
114- schema_id = self .event_schema_id ,
115- data = {"action" : action , "kernel_id" : self .kernel_id , "caller" : "kernel_manager" },
116- )
117-
11894 _ready : t .Union [Future , CFuture ]
11995
12096 def __init__ (self , * args , ** kwargs ):
@@ -333,7 +309,6 @@ async def _async_launch_kernel(self, kernel_cmd: t.List[str], **kw: t.Any) -> No
333309 assert self .provisioner .has_process
334310 # Provisioner provides the connection information. Load into kernel manager and write file.
335311 self ._force_connection_info (connection_info )
336- self ._emit (action = "launch" )
337312
338313 _launch_kernel = run_sync (_async_launch_kernel )
339314
@@ -376,7 +351,6 @@ async def _async_pre_start_kernel(
376351 )
377352 kw = await self .provisioner .pre_launch (** kw )
378353 kernel_cmd = kw .pop ('cmd' )
379- self ._emit (action = "pre_start" )
380354 return kernel_cmd , kw
381355
382356 pre_start_kernel = run_sync (_async_pre_start_kernel )
@@ -393,7 +367,6 @@ async def _async_post_start_kernel(self, **kw: t.Any) -> None:
393367 self ._connect_control_socket ()
394368 assert self .provisioner is not None
395369 await self .provisioner .post_launch (** kw )
396- self ._emit (action = "post_start" )
397370
398371 post_start_kernel = run_sync (_async_post_start_kernel )
399372
@@ -430,7 +403,6 @@ async def _async_request_shutdown(self, restart: bool = False) -> None:
430403 assert self .provisioner is not None
431404 await self .provisioner .shutdown_requested (restart = restart )
432405 self ._shutdown_status = _ShutdownStatus .ShutdownRequest
433- self ._emit (action = "request_shutdown" )
434406
435407 request_shutdown = run_sync (_async_request_shutdown )
436408
@@ -472,7 +444,6 @@ async def _async_finish_shutdown(
472444 if self .has_kernel :
473445 assert self .provisioner is not None
474446 await self .provisioner .wait ()
475- self ._emit (action = "finish_shutdown" )
476447
477448 finish_shutdown = run_sync (_async_finish_shutdown )
478449
@@ -490,7 +461,6 @@ async def _async_cleanup_resources(self, restart: bool = False) -> None:
490461
491462 if self .provisioner :
492463 await self .provisioner .cleanup (restart = restart )
493- self ._emit (action = "cleanup_resources" )
494464
495465 cleanup_resources = run_sync (_async_cleanup_resources )
496466
@@ -513,7 +483,6 @@ async def _async_shutdown_kernel(self, now: bool = False, restart: bool = False)
513483 Will this kernel be restarted after it is shutdown. When this
514484 is True, connection files will not be cleaned up.
515485 """
516- self ._emit (action = "shutdown_started" )
517486 self .shutting_down = True # Used by restarter to prevent race condition
518487 # Stop monitoring for restarting while we shutdown.
519488 self .stop_restarter ()
@@ -531,7 +500,6 @@ async def _async_shutdown_kernel(self, now: bool = False, restart: bool = False)
531500 await self ._async_finish_shutdown (restart = restart )
532501
533502 await self ._async_cleanup_resources (restart = restart )
534- self ._emit (action = "shutdown_finished" )
535503
536504 shutdown_kernel = run_sync (_async_shutdown_kernel )
537505
@@ -562,7 +530,6 @@ async def _async_restart_kernel(
562530 Any options specified here will overwrite those used to launch the
563531 kernel.
564532 """
565- self ._emit (action = "restart_started" )
566533 if self ._launch_args is None :
567534 raise RuntimeError ("Cannot restart the kernel. No previous call to 'start_kernel'." )
568535
@@ -575,7 +542,6 @@ async def _async_restart_kernel(
575542 # Start new kernel.
576543 self ._launch_args .update (kw )
577544 await self ._async_start_kernel (** self ._launch_args )
578- self ._emit (action = "restart_finished" )
579545
580546 restart_kernel = run_sync (_async_restart_kernel )
581547
@@ -612,7 +578,6 @@ async def _async_kill_kernel(self, restart: bool = False) -> None:
612578 # Process is no longer alive, wait and clear
613579 if self .has_kernel :
614580 await self .provisioner .wait ()
615- self ._emit (action = "kill" )
616581
617582 _kill_kernel = run_sync (_async_kill_kernel )
618583
@@ -634,7 +599,6 @@ async def _async_interrupt_kernel(self) -> None:
634599 self .session .send (self ._control_socket , msg )
635600 else :
636601 raise RuntimeError ("Cannot interrupt kernel. No kernel is running!" )
637- self ._emit (action = "interrupt" )
638602
639603 interrupt_kernel = run_sync (_async_interrupt_kernel )
640604
0 commit comments