15
15
from enum import Enum
16
16
17
17
import zmq
18
- from jupyter_events import EventLogger # type: ignore[import]
19
18
from traitlets import Any
20
19
from traitlets import Bool
21
20
from traitlets import default
33
32
from .provisioning import KernelProvisionerBase
34
33
from .provisioning import KernelProvisionerFactory as KPF
35
34
from .utils import run_sync
36
- from jupyter_client import DEFAULT_EVENTS_SCHEMA_PATH
37
- from jupyter_client import JUPYTER_CLIENT_EVENTS_URI
38
35
from jupyter_client import KernelClient
39
36
from jupyter_client import kernelspec
40
37
@@ -94,27 +91,6 @@ class KernelManager(ConnectionFileMixin):
94
91
This version starts kernels with Popen.
95
92
"""
96
93
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
-
118
94
_ready : t .Union [Future , CFuture ]
119
95
120
96
def __init__ (self , * args , ** kwargs ):
@@ -333,7 +309,6 @@ async def _async_launch_kernel(self, kernel_cmd: t.List[str], **kw: t.Any) -> No
333
309
assert self .provisioner .has_process
334
310
# Provisioner provides the connection information. Load into kernel manager and write file.
335
311
self ._force_connection_info (connection_info )
336
- self ._emit (action = "launch" )
337
312
338
313
_launch_kernel = run_sync (_async_launch_kernel )
339
314
@@ -376,7 +351,6 @@ async def _async_pre_start_kernel(
376
351
)
377
352
kw = await self .provisioner .pre_launch (** kw )
378
353
kernel_cmd = kw .pop ('cmd' )
379
- self ._emit (action = "pre_start" )
380
354
return kernel_cmd , kw
381
355
382
356
pre_start_kernel = run_sync (_async_pre_start_kernel )
@@ -393,7 +367,6 @@ async def _async_post_start_kernel(self, **kw: t.Any) -> None:
393
367
self ._connect_control_socket ()
394
368
assert self .provisioner is not None
395
369
await self .provisioner .post_launch (** kw )
396
- self ._emit (action = "post_start" )
397
370
398
371
post_start_kernel = run_sync (_async_post_start_kernel )
399
372
@@ -430,7 +403,6 @@ async def _async_request_shutdown(self, restart: bool = False) -> None:
430
403
assert self .provisioner is not None
431
404
await self .provisioner .shutdown_requested (restart = restart )
432
405
self ._shutdown_status = _ShutdownStatus .ShutdownRequest
433
- self ._emit (action = "request_shutdown" )
434
406
435
407
request_shutdown = run_sync (_async_request_shutdown )
436
408
@@ -472,7 +444,6 @@ async def _async_finish_shutdown(
472
444
if self .has_kernel :
473
445
assert self .provisioner is not None
474
446
await self .provisioner .wait ()
475
- self ._emit (action = "finish_shutdown" )
476
447
477
448
finish_shutdown = run_sync (_async_finish_shutdown )
478
449
@@ -490,7 +461,6 @@ async def _async_cleanup_resources(self, restart: bool = False) -> None:
490
461
491
462
if self .provisioner :
492
463
await self .provisioner .cleanup (restart = restart )
493
- self ._emit (action = "cleanup_resources" )
494
464
495
465
cleanup_resources = run_sync (_async_cleanup_resources )
496
466
@@ -513,7 +483,6 @@ async def _async_shutdown_kernel(self, now: bool = False, restart: bool = False)
513
483
Will this kernel be restarted after it is shutdown. When this
514
484
is True, connection files will not be cleaned up.
515
485
"""
516
- self ._emit (action = "shutdown_started" )
517
486
self .shutting_down = True # Used by restarter to prevent race condition
518
487
# Stop monitoring for restarting while we shutdown.
519
488
self .stop_restarter ()
@@ -531,7 +500,6 @@ async def _async_shutdown_kernel(self, now: bool = False, restart: bool = False)
531
500
await self ._async_finish_shutdown (restart = restart )
532
501
533
502
await self ._async_cleanup_resources (restart = restart )
534
- self ._emit (action = "shutdown_finished" )
535
503
536
504
shutdown_kernel = run_sync (_async_shutdown_kernel )
537
505
@@ -562,7 +530,6 @@ async def _async_restart_kernel(
562
530
Any options specified here will overwrite those used to launch the
563
531
kernel.
564
532
"""
565
- self ._emit (action = "restart_started" )
566
533
if self ._launch_args is None :
567
534
raise RuntimeError ("Cannot restart the kernel. No previous call to 'start_kernel'." )
568
535
@@ -575,7 +542,6 @@ async def _async_restart_kernel(
575
542
# Start new kernel.
576
543
self ._launch_args .update (kw )
577
544
await self ._async_start_kernel (** self ._launch_args )
578
- self ._emit (action = "restart_finished" )
579
545
580
546
restart_kernel = run_sync (_async_restart_kernel )
581
547
@@ -612,7 +578,6 @@ async def _async_kill_kernel(self, restart: bool = False) -> None:
612
578
# Process is no longer alive, wait and clear
613
579
if self .has_kernel :
614
580
await self .provisioner .wait ()
615
- self ._emit (action = "kill" )
616
581
617
582
_kill_kernel = run_sync (_async_kill_kernel )
618
583
@@ -634,7 +599,6 @@ async def _async_interrupt_kernel(self) -> None:
634
599
self .session .send (self ._control_socket , msg )
635
600
else :
636
601
raise RuntimeError ("Cannot interrupt kernel. No kernel is running!" )
637
- self ._emit (action = "interrupt" )
638
602
639
603
interrupt_kernel = run_sync (_async_interrupt_kernel )
640
604
0 commit comments