Show More
@@ -1,193 +1,127 b'' | |||
|
1 | 1 | """Abstract base classes for kernel client channels""" |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (C) 2013 The IPython Development Team |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the BSD License. The full license is in |
|
7 | 7 | # the file COPYING, distributed as part of this software. |
|
8 | 8 | #----------------------------------------------------------------------------- |
|
9 | 9 | |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | # Imports |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | # Standard library imports |
|
15 | 15 | import abc |
|
16 | 16 | |
|
17 | 17 | #----------------------------------------------------------------------------- |
|
18 | 18 | # Channels |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | class ChannelABC(object): |
|
23 | 23 | """A base class for all channel ABCs.""" |
|
24 | 24 | |
|
25 | 25 | __metaclass__ = abc.ABCMeta |
|
26 | 26 | |
|
27 | 27 | @abc.abstractmethod |
|
28 | 28 | def start(self): |
|
29 | 29 | pass |
|
30 | 30 | |
|
31 | 31 | @abc.abstractmethod |
|
32 | 32 | def stop(self): |
|
33 | 33 | pass |
|
34 | 34 | |
|
35 | 35 | @abc.abstractmethod |
|
36 | 36 | def is_alive(self): |
|
37 | 37 | pass |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | class ShellChannelABC(ChannelABC): |
|
41 | 41 | """ShellChannel ABC. |
|
42 | 42 | |
|
43 | 43 | The docstrings for this class can be found in the base implementation: |
|
44 | 44 | |
|
45 | 45 | `IPython.kernel.channels.ShellChannel` |
|
46 | 46 | """ |
|
47 | 47 | |
|
48 | 48 | @abc.abstractproperty |
|
49 | 49 | def allow_stdin(self): |
|
50 | 50 | pass |
|
51 | 51 | |
|
52 | 52 | @abc.abstractmethod |
|
53 | 53 | def execute(self, code, silent=False, store_history=True, |
|
54 | 54 | user_variables=None, user_expressions=None, allow_stdin=None): |
|
55 | 55 | pass |
|
56 | 56 | |
|
57 | 57 | @abc.abstractmethod |
|
58 | 58 | def complete(self, text, line, cursor_pos, block=None): |
|
59 | 59 | pass |
|
60 | 60 | |
|
61 | 61 | @abc.abstractmethod |
|
62 | 62 | def object_info(self, oname, detail_level=0): |
|
63 | 63 | pass |
|
64 | 64 | |
|
65 | 65 | @abc.abstractmethod |
|
66 | 66 | def history(self, raw=True, output=False, hist_access_type='range', **kwargs): |
|
67 | 67 | pass |
|
68 | 68 | |
|
69 | 69 | @abc.abstractmethod |
|
70 | 70 | def kernel_info(self): |
|
71 | 71 | pass |
|
72 | 72 | |
|
73 | 73 | @abc.abstractmethod |
|
74 | 74 | def shutdown(self, restart=False): |
|
75 | 75 | pass |
|
76 | 76 | |
|
77 | 77 | |
|
78 | 78 | class IOPubChannelABC(ChannelABC): |
|
79 | 79 | """IOPubChannel ABC. |
|
80 | 80 | |
|
81 | 81 | The docstrings for this class can be found in the base implementation: |
|
82 | 82 | |
|
83 | 83 | `IPython.kernel.channels.IOPubChannel` |
|
84 | 84 | """ |
|
85 | 85 | |
|
86 | 86 | @abc.abstractmethod |
|
87 | 87 | def flush(self, timeout=1.0): |
|
88 | 88 | pass |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | class StdInChannelABC(ChannelABC): |
|
92 | 92 | """StdInChannel ABC. |
|
93 | 93 | |
|
94 | 94 | The docstrings for this class can be found in the base implementation: |
|
95 | 95 | |
|
96 | 96 | `IPython.kernel.channels.StdInChannel` |
|
97 | 97 | """ |
|
98 | 98 | |
|
99 | 99 | @abc.abstractmethod |
|
100 | 100 | def input(self, string): |
|
101 | 101 | pass |
|
102 | 102 | |
|
103 | 103 | |
|
104 | 104 | class HBChannelABC(ChannelABC): |
|
105 | 105 | """HBChannel ABC. |
|
106 | 106 | |
|
107 | 107 | The docstrings for this class can be found in the base implementation: |
|
108 | 108 | |
|
109 | 109 | `IPython.kernel.channels.HBChannel` |
|
110 | 110 | """ |
|
111 | 111 | |
|
112 | 112 | @abc.abstractproperty |
|
113 | 113 | def time_to_dead(self): |
|
114 | 114 | pass |
|
115 | 115 | |
|
116 | 116 | @abc.abstractmethod |
|
117 | 117 | def pause(self): |
|
118 | 118 | pass |
|
119 | 119 | |
|
120 | 120 | @abc.abstractmethod |
|
121 | 121 | def unpause(self): |
|
122 | 122 | pass |
|
123 | 123 | |
|
124 | 124 | @abc.abstractmethod |
|
125 | 125 | def is_beating(self): |
|
126 | 126 | pass |
|
127 | 127 | |
|
128 | ||
|
129 | #----------------------------------------------------------------------------- | |
|
130 | # Main kernel manager class | |
|
131 | #----------------------------------------------------------------------------- | |
|
132 | ||
|
133 | class KernelClientABC(object): | |
|
134 | """KernelManager ABC. | |
|
135 | ||
|
136 | The docstrings for this class can be found in the base implementation: | |
|
137 | ||
|
138 | `IPython.kernel.channels.KernelClient` | |
|
139 | """ | |
|
140 | ||
|
141 | __metaclass__ = abc.ABCMeta | |
|
142 | ||
|
143 | @abc.abstractproperty | |
|
144 | def kernel(self): | |
|
145 | pass | |
|
146 | ||
|
147 | @abc.abstractproperty | |
|
148 | def shell_channel_class(self): | |
|
149 | pass | |
|
150 | ||
|
151 | @abc.abstractproperty | |
|
152 | def iopub_channel_class(self): | |
|
153 | pass | |
|
154 | ||
|
155 | @abc.abstractproperty | |
|
156 | def hb_channel_class(self): | |
|
157 | pass | |
|
158 | ||
|
159 | @abc.abstractproperty | |
|
160 | def stdin_channel_class(self): | |
|
161 | pass | |
|
162 | ||
|
163 | #-------------------------------------------------------------------------- | |
|
164 | # Channel management methods | |
|
165 | #-------------------------------------------------------------------------- | |
|
166 | ||
|
167 | @abc.abstractmethod | |
|
168 | def start_channels(self, shell=True, iopub=True, stdin=True, hb=True): | |
|
169 | pass | |
|
170 | ||
|
171 | @abc.abstractmethod | |
|
172 | def stop_channels(self): | |
|
173 | pass | |
|
174 | ||
|
175 | @abc.abstractproperty | |
|
176 | def channels_running(self): | |
|
177 | pass | |
|
178 | ||
|
179 | @abc.abstractproperty | |
|
180 | def shell_channel(self): | |
|
181 | pass | |
|
182 | ||
|
183 | @abc.abstractproperty | |
|
184 | def iopub_channel(self): | |
|
185 | pass | |
|
186 | ||
|
187 | @abc.abstractproperty | |
|
188 | def stdin_channel(self): | |
|
189 | pass | |
|
190 | ||
|
191 | @abc.abstractproperty | |
|
192 | def hb_channel(self): | |
|
193 | pass |
@@ -1,193 +1,81 b'' | |||
|
1 |
"""Abstract base class |
|
|
1 | """Abstract base class for kernel clients""" | |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (C) 2013 The IPython Development Team |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the BSD License. The full license is in |
|
7 | 7 | # the file COPYING, distributed as part of this software. |
|
8 | 8 | #----------------------------------------------------------------------------- |
|
9 | 9 | |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | # Imports |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | # Standard library imports |
|
15 | 15 | import abc |
|
16 | 16 | |
|
17 | 17 | #----------------------------------------------------------------------------- |
|
18 | # Channels | |
|
19 | #----------------------------------------------------------------------------- | |
|
20 | ||
|
21 | ||
|
22 | class ChannelABC(object): | |
|
23 | """A base class for all channel ABCs.""" | |
|
24 | ||
|
25 | __metaclass__ = abc.ABCMeta | |
|
26 | ||
|
27 | @abc.abstractmethod | |
|
28 | def start(self): | |
|
29 | pass | |
|
30 | ||
|
31 | @abc.abstractmethod | |
|
32 | def stop(self): | |
|
33 | pass | |
|
34 | ||
|
35 | @abc.abstractmethod | |
|
36 | def is_alive(self): | |
|
37 | pass | |
|
38 | ||
|
39 | ||
|
40 | class ShellChannelABC(ChannelABC): | |
|
41 | """ShellChannel ABC. | |
|
42 | ||
|
43 | The docstrings for this class can be found in the base implementation: | |
|
44 | ||
|
45 | `IPython.kernel.kernelmanager.ShellChannel` | |
|
46 | """ | |
|
47 | ||
|
48 | @abc.abstractproperty | |
|
49 | def allow_stdin(self): | |
|
50 | pass | |
|
51 | ||
|
52 | @abc.abstractmethod | |
|
53 | def execute(self, code, silent=False, store_history=True, | |
|
54 | user_variables=None, user_expressions=None, allow_stdin=None): | |
|
55 | pass | |
|
56 | ||
|
57 | @abc.abstractmethod | |
|
58 | def complete(self, text, line, cursor_pos, block=None): | |
|
59 | pass | |
|
60 | ||
|
61 | @abc.abstractmethod | |
|
62 | def object_info(self, oname, detail_level=0): | |
|
63 | pass | |
|
64 | ||
|
65 | @abc.abstractmethod | |
|
66 | def history(self, raw=True, output=False, hist_access_type='range', **kwargs): | |
|
67 | pass | |
|
68 | ||
|
69 | @abc.abstractmethod | |
|
70 | def kernel_info(self): | |
|
71 | pass | |
|
72 | ||
|
73 | @abc.abstractmethod | |
|
74 | def shutdown(self, restart=False): | |
|
75 | pass | |
|
76 | ||
|
77 | ||
|
78 | class IOPubChannelABC(ChannelABC): | |
|
79 | """IOPubChannel ABC. | |
|
80 | ||
|
81 | The docstrings for this class can be found in the base implementation: | |
|
82 | ||
|
83 | `IPython.kernel.kernelmanager.IOPubChannel` | |
|
84 | """ | |
|
85 | ||
|
86 | @abc.abstractmethod | |
|
87 | def flush(self, timeout=1.0): | |
|
88 | pass | |
|
89 | ||
|
90 | ||
|
91 | class StdInChannelABC(ChannelABC): | |
|
92 | """StdInChannel ABC. | |
|
93 | ||
|
94 | The docstrings for this class can be found in the base implementation: | |
|
95 | ||
|
96 | `IPython.kernel.kernelmanager.StdInChannel` | |
|
97 | """ | |
|
98 | ||
|
99 | @abc.abstractmethod | |
|
100 | def input(self, string): | |
|
101 | pass | |
|
102 | ||
|
103 | ||
|
104 | class HBChannelABC(ChannelABC): | |
|
105 | """HBChannel ABC. | |
|
106 | ||
|
107 | The docstrings for this class can be found in the base implementation: | |
|
108 | ||
|
109 | `IPython.kernel.kernelmanager.HBChannel` | |
|
110 | """ | |
|
111 | ||
|
112 | @abc.abstractproperty | |
|
113 | def time_to_dead(self): | |
|
114 | pass | |
|
115 | ||
|
116 | @abc.abstractmethod | |
|
117 | def pause(self): | |
|
118 | pass | |
|
119 | ||
|
120 | @abc.abstractmethod | |
|
121 | def unpause(self): | |
|
122 | pass | |
|
123 | ||
|
124 | @abc.abstractmethod | |
|
125 | def is_beating(self): | |
|
126 | pass | |
|
127 | ||
|
128 | ||
|
129 | #----------------------------------------------------------------------------- | |
|
130 | # Main kernel manager class | |
|
18 | # Main kernel client class | |
|
131 | 19 | #----------------------------------------------------------------------------- |
|
132 | 20 | |
|
133 | 21 | class KernelClientABC(object): |
|
134 | 22 | """KernelManager ABC. |
|
135 | 23 | |
|
136 | 24 | The docstrings for this class can be found in the base implementation: |
|
137 | 25 | |
|
138 |
`IPython.kernel. |
|
|
26 | `IPython.kernel.client.KernelClient` | |
|
139 | 27 | """ |
|
140 | 28 | |
|
141 | 29 | __metaclass__ = abc.ABCMeta |
|
142 | 30 | |
|
143 | 31 | @abc.abstractproperty |
|
144 | 32 | def kernel(self): |
|
145 | 33 | pass |
|
146 | 34 | |
|
147 | 35 | @abc.abstractproperty |
|
148 | 36 | def shell_channel_class(self): |
|
149 | 37 | pass |
|
150 | 38 | |
|
151 | 39 | @abc.abstractproperty |
|
152 | 40 | def iopub_channel_class(self): |
|
153 | 41 | pass |
|
154 | 42 | |
|
155 | 43 | @abc.abstractproperty |
|
156 | 44 | def hb_channel_class(self): |
|
157 | 45 | pass |
|
158 | 46 | |
|
159 | 47 | @abc.abstractproperty |
|
160 | 48 | def stdin_channel_class(self): |
|
161 | 49 | pass |
|
162 | 50 | |
|
163 | 51 | #-------------------------------------------------------------------------- |
|
164 | 52 | # Channel management methods |
|
165 | 53 | #-------------------------------------------------------------------------- |
|
166 | 54 | |
|
167 | 55 | @abc.abstractmethod |
|
168 | 56 | def start_channels(self, shell=True, iopub=True, stdin=True, hb=True): |
|
169 | 57 | pass |
|
170 | 58 | |
|
171 | 59 | @abc.abstractmethod |
|
172 | 60 | def stop_channels(self): |
|
173 | 61 | pass |
|
174 | 62 | |
|
175 | 63 | @abc.abstractproperty |
|
176 | 64 | def channels_running(self): |
|
177 | 65 | pass |
|
178 | 66 | |
|
179 | 67 | @abc.abstractproperty |
|
180 | 68 | def shell_channel(self): |
|
181 | 69 | pass |
|
182 | 70 | |
|
183 | 71 | @abc.abstractproperty |
|
184 | 72 | def iopub_channel(self): |
|
185 | 73 | pass |
|
186 | 74 | |
|
187 | 75 | @abc.abstractproperty |
|
188 | 76 | def stdin_channel(self): |
|
189 | 77 | pass |
|
190 | 78 | |
|
191 | 79 | @abc.abstractproperty |
|
192 | 80 | def hb_channel(self): |
|
193 | 81 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now