Debian Codegraph @

jupyter_client/clientabc.py

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