shell
Defines the shell base class.
Classes:
-
BaseShell–The base shell implementation.
BaseShell
¶
Bases: HasInterface[T_interface_co], LoggingConfigurable, Generic[T_interface_co]
The base shell implementation.
This should be the left most inherited class to be used.
-
Reference
shell
BaseShellget_ipython
Methods:
-
stop–Stop the shell.
-
reset–Reset the shell, cancelling all associated pending.
-
get_ipython–Return the shell for the current context.
-
context–A context manager where the shell is active.
-
displayhook–Publish execution results.
-
do_execute–Execute code in the shell.
-
do_complete– -
is_complete– -
do_inspect– -
do_history–
Attributes:
-
kernel(Fixed[Self, Kernel[T_interface_co, Self]]) – -
pending_manager–Provides the
subshell_idfor the shell which add all consenting pending created in -
user_ns_hidden(Fixed[Self, dict]) – -
timeout–A timeout in seconds to complete execute requests.
-
stop_on_error_time_offset–An offset to add to the cancellation time to catch late arriving execute requests.
-
protected–Protect from accidental deletion.
-
is_mainshell–Set by the mainshell to indicate it is the main shell.
-
subshell_id(Fixed[Self, str | None]) –Used to identify the subshell.
Source code in src/async_kernel/shell/base.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
kernel
class-attribute
instance-attribute
¶
pending_manager
class-attribute
instance-attribute
¶
pending_manager = Fixed(ShellPendingManager)
Provides the subshell_id for the shell which add all consenting pending created in
the context of the shell.
timeout
class-attribute
instance-attribute
¶
timeout = traitlets.CFloat(0.0).tag(config=True)
A timeout in seconds to complete execute requests.
stop_on_error_time_offset
class-attribute
instance-attribute
¶
stop_on_error_time_offset = traitlets.Float(0.0).tag(config=True)
An offset to add to the cancellation time to catch late arriving execute requests.
protected
class-attribute
instance-attribute
¶
protected = traitlets.Bool(read_only=True)
Protect from accidental deletion.
is_mainshell
class-attribute
instance-attribute
¶
is_mainshell = traitlets.Bool(False, read_only=True)
Set by the mainshell to indicate it is the main shell.
subshell_id
class-attribute
instance-attribute
¶
subshell_id: Fixed[Self, str | None] = Fixed(
lambda c: None if c["owner"].is_mainshell else c["owner"].pending_manager.id
)
Used to identify the subshell.
stop
¶
Stop the shell.
Parameters:
-
Reference
kernel
Kernelcreate_subshell
Source code in src/async_kernel/shell/base.py
159 160 161 162 163 164 165 166 167 168 169 170 171 | |
reset
¶
reset(new_session=True, aggressive=False) -> None
Reset the shell, cancelling all associated pending.
Source code in src/async_kernel/shell/base.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
get_ipython
¶
get_ipython() -> BaseShell
Return the shell for the current context.
Source code in src/async_kernel/shell/base.py
186 187 188 | |
context
¶
A context manager where the shell is active.
Source code in src/async_kernel/shell/base.py
190 191 192 193 194 | |
displayhook
¶
displayhook(result: Any) -> None
Publish execution results.
This is invoked every time the interpreter needs to print, and is activated by setting the variable sys.displayhook to it.
Source code in src/async_kernel/shell/base.py
196 197 198 199 200 201 202 203 204 205 206 207 208 | |
do_execute
async
¶
do_execute(
code: str = "",
*,
silent: bool = False,
store_history: bool = False,
user_expressions: dict[str, str] | None = None,
allow_stdin: bool = False,
stop_on_error: bool = False,
cell_id: str | None = None,
received_time: float = 0,
tags: Iterable[str] = (),
**_ignored,
) -> Content
Execute code in the shell.
Source code in src/async_kernel/shell/base.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
do_complete
async
¶
Source code in src/async_kernel/shell/base.py
229 230 231 | |
is_complete
async
¶
Source code in src/async_kernel/shell/base.py
233 234 235 | |
do_inspect
async
¶
Source code in src/async_kernel/shell/base.py
237 238 239 | |
do_history
async
¶
do_history(
*,
output: bool = False,
raw: bool = True,
hist_access_type: str,
session: int = 0,
start: int = 1,
stop: int | None = None,
n: int = 10,
pattern: str = "*",
unique: bool = False,
**_ignored,
) -> Content
Source code in src/async_kernel/shell/base.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |