1"""Abstract base class for kernel clients"""
2# -----------------------------------------------------------------------------
3# Copyright (c) The Jupyter Development Team
4#
5# Distributed under the terms of the BSD License. The full license is in
6# the file COPYING, distributed as part of this software.
7# -----------------------------------------------------------------------------
8# -----------------------------------------------------------------------------
9# Imports
10# -----------------------------------------------------------------------------
11from __future__ import annotations
12
13import abc
14from typing import TYPE_CHECKING, Any
15
16if TYPE_CHECKING:
17 from .channelsabc import ChannelABC
18
19# -----------------------------------------------------------------------------
20# Main kernel client class
21# -----------------------------------------------------------------------------
22
23
24class KernelClientABC(metaclass=abc.ABCMeta):
25 """KernelManager ABC.
26
27 The docstrings for this class can be found in the base implementation:
28
29 `jupyter_client.client.KernelClient`
30 """
31
32 @abc.abstractproperty
33 def kernel(self) -> Any:
34 pass
35
36 @abc.abstractproperty
37 def shell_channel_class(self) -> type[ChannelABC]:
38 pass
39
40 @abc.abstractproperty
41 def iopub_channel_class(self) -> type[ChannelABC]:
42 pass
43
44 @abc.abstractproperty
45 def hb_channel_class(self) -> type[ChannelABC]:
46 pass
47
48 @abc.abstractproperty
49 def stdin_channel_class(self) -> type[ChannelABC]:
50 pass
51
52 @abc.abstractproperty
53 def control_channel_class(self) -> type[ChannelABC]:
54 pass
55
56 # --------------------------------------------------------------------------
57 # Channel management methods
58 # --------------------------------------------------------------------------
59
60 @abc.abstractmethod
61 def start_channels(
62 self,
63 shell: bool = True,
64 iopub: bool = True,
65 stdin: bool = True,
66 hb: bool = True,
67 control: bool = True,
68 ) -> None:
69 """Start the channels for the client."""
70 pass
71
72 @abc.abstractmethod
73 def stop_channels(self) -> None:
74 """Stop the channels for the client."""
75 pass
76
77 @abc.abstractproperty
78 def channels_running(self) -> bool:
79 """Get whether the channels are running."""
80 pass
81
82 @abc.abstractproperty
83 def shell_channel(self) -> ChannelABC:
84 pass
85
86 @abc.abstractproperty
87 def iopub_channel(self) -> ChannelABC:
88 pass
89
90 @abc.abstractproperty
91 def stdin_channel(self) -> ChannelABC:
92 pass
93
94 @abc.abstractproperty
95 def hb_channel(self) -> ChannelABC:
96 pass
97
98 @abc.abstractproperty
99 def control_channel(self) -> ChannelABC:
100 pass