typing
Classes:
-
Channel–An enum of channelsRef.
-
RunMode–An Enum of the run modes available for handling Messages.
-
MsgType–An enumeration of Message
msg_typefor shell and control messages. -
Tags–Tags recognised by the shell.
-
CallerState–The State of a async_kernel.caller.Caller.
-
MsgHeader– -
Message–A message.
-
Job–A
Messagebundle. -
ExecuteContent–Ref.
-
FixedCreate–A TypedDict relevant to Fixed.
-
FixedCreated–A TypedDict relevant to Fixed.
-
CallerCreateOptions–Options to use when creating an instance of a Caller.
Attributes:
-
NoValue–A sentinel to indicate a value has not been provided.
-
DebugMessage–A TypeAlias for a debug message.
-
Content–A TypeAlias for the content in
Message. -
HandlerType–A TypeAlias for the handler of message requests.
NoValue
module-attribute
¶
NoValue = Sentinel('NoValue')
A sentinel to indicate a value has not been provided.
DebugMessage
module-attribute
¶
A TypeAlias for a debug message.
Content
module-attribute
¶
A TypeAlias for the content in Message.
Notes
- The content of a message handler can provide 'buffers'. When present, the buffers are extracted from dict and handled separately by the interface.
- Reference
- Reference
HandlerType
module-attribute
¶
A TypeAlias for the handler of message requests.
-
Reference
kernel
Kernelrun_handler
Channel
¶
Bases: StrEnum
An enum of channelsRef.
- Reference
- Reference interface
Attributes:
Source code in src/async_kernel/typing.py
51 52 53 54 55 56 57 58 59 60 61 62 63 | |
RunMode
¶
Bases: StrEnum
An Enum of the run modes available for handling Messages.
async_kernel.kernel.Kernel.msg_handler uses get_run_mode
to map the message type and channel (shell or control) to the RunMode.
Cell overrides
The user can also specify an execution mode in execute requests.
Top line comment:
# task
```python
##task
```
Attributes:
-
queue–Run the message handler using async_kernel.caller.Caller.queue_call.
-
task–Run the message handler using async_kernel.caller.Caller.call_soon.
-
thread–Run the message handler using async_kernel.caller.Caller.to_thread to start use a 'worker'.
-
direct–Run the message handler using async_kernel.caller.Caller.call_direct.
Source code in src/async_kernel/typing.py
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 | |
queue
class-attribute
instance-attribute
¶
queue = 'queue'
Run the message handler using async_kernel.caller.Caller.queue_call.
task
class-attribute
instance-attribute
¶
task = 'task'
Run the message handler using async_kernel.caller.Caller.call_soon.
thread
class-attribute
instance-attribute
¶
thread = 'thread'
Run the message handler using async_kernel.caller.Caller.to_thread to start use a 'worker'.
direct
class-attribute
instance-attribute
¶
direct = 'direct'
Run the message handler using async_kernel.caller.Caller.call_direct.
Warning
- This mode runs directly in the caller scheduler as soon as it is received.
- Use this only for fast running high priority code.
MsgType
¶
Bases: StrEnum
An enumeration of Message msg_type for shell and control messages.
Some message types are on the control channel only.
-
Reference
kernel
Kernelrun_handler
Attributes:
-
kernel_info_request– -
comm_info_request– -
execute_request– -
complete_request– -
is_complete_request– -
inspect_request– -
history_request– -
comm_open– -
comm_msg– -
comm_close– -
interrupt_request–async_kernel.kernel.Kernel.interrupt_request (control channel only)
-
shutdown_request–async_kernel.kernel.Kernel.shutdown_request (control channel only)
-
debug_request–async_kernel.kernel.Kernel.debug_request (control channel only)
-
create_subshell_request–async_kernel.kernel.Kernel.create_subshell_request (control channel only)
-
delete_subshell_request–async_kernel.kernel.Kernel.delete_subshell_request (control channel only)
-
list_subshell_request–async_kernel.kernel.Kernel.debug_request (control channel only)
Source code in src/async_kernel/typing.py
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 | |
kernel_info_request
class-attribute
instance-attribute
¶
kernel_info_request = 'kernel_info_request'
comm_info_request
class-attribute
instance-attribute
¶
comm_info_request = 'comm_info_request'
execute_request
class-attribute
instance-attribute
¶
execute_request = 'execute_request'
complete_request
class-attribute
instance-attribute
¶
complete_request = 'complete_request'
is_complete_request
class-attribute
instance-attribute
¶
is_complete_request = 'is_complete_request'
inspect_request
class-attribute
instance-attribute
¶
inspect_request = 'inspect_request'
history_request
class-attribute
instance-attribute
¶
history_request = 'history_request'
comm_open
class-attribute
instance-attribute
¶
comm_open = 'comm_open'
comm_msg
class-attribute
instance-attribute
¶
comm_msg = 'comm_msg'
comm_close
class-attribute
instance-attribute
¶
comm_close = 'comm_close'
interrupt_request
class-attribute
instance-attribute
¶
interrupt_request = 'interrupt_request'
async_kernel.kernel.Kernel.interrupt_request (control channel only)
shutdown_request
class-attribute
instance-attribute
¶
shutdown_request = 'shutdown_request'
async_kernel.kernel.Kernel.shutdown_request (control channel only)
debug_request
class-attribute
instance-attribute
¶
debug_request = 'debug_request'
async_kernel.kernel.Kernel.debug_request (control channel only)
create_subshell_request
class-attribute
instance-attribute
¶
create_subshell_request = 'create_subshell_request'
async_kernel.kernel.Kernel.create_subshell_request (control channel only)
delete_subshell_request
class-attribute
instance-attribute
¶
delete_subshell_request = 'delete_subshell_request'
async_kernel.kernel.Kernel.delete_subshell_request (control channel only)
list_subshell_request
class-attribute
instance-attribute
¶
list_subshell_request = 'list_subshell_request'
async_kernel.kernel.Kernel.debug_request (control channel only)
Tags
¶
Bases: StrEnum
Tags recognised by the shell.
Info
Tags are can be added per cell.
- Jupyter: via the right side bar.
- VScode: via Jupyter variables explorer
-
Reference
utils
get_tag_value
Attributes:
-
raises_exception–Indicates the cell should expect an exception to be raised.
-
suppress_error–Suppress exceptions that occur during execution of the code cell.
-
stop_on_error–Override
stop_on_error. -
timeout–Specify a timeout in seconds for code execution to complete.
Source code in src/async_kernel/typing.py
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 257 | |
raises_exception
class-attribute
instance-attribute
¶
raises_exception = 'raises-exception'
Indicates the cell should expect an exception to be raised.
Notes
- When an exception is raised, stop_on_error is False/
- When an exception is not raised an exception will be raise and stop_on_error is True.
suppress_error
class-attribute
instance-attribute
¶
suppress_error = 'suppress-error'
Suppress exceptions that occur during execution of the code cell.
The default message is '⚠'
Examples:
- suppress-error
- suppress-error=The suppression message.
Warning
The code block will return as 'ok' (not published).
- About Contributing Development Notebooks
stop_on_error
class-attribute
instance-attribute
¶
stop_on_error = 'stop-on-error'
Override stop_on_error.
Examples:
- True
- stop_on_error=true
- stop_on_error=True
- False
- stop_on_error=False
timeout
class-attribute
instance-attribute
¶
timeout = 'timeout='
Specify a timeout in seconds for code execution to complete.
Examples:
- timeout=0.0 (no timeout)
- timeout=0.1 (100 ms)
CallerState
¶
Bases: Enum
The State of a async_kernel.caller.Caller.
Source code in src/async_kernel/typing.py
260 261 262 263 264 265 266 267 | |
MsgHeader
¶
Bases: TypedDict
Attributes:
-
msg_id(str) – -
session(str) – -
username(str) – -
date(str | datetime) – -
msg_type(MsgType | str) – -
version(str) – -
subshell_id(NotRequired[str | None]) –
Source code in src/async_kernel/typing.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
Message
¶
A message.
- Reference
Attributes:
-
channel(Channel) –The channel of the message.
-
header(MsgHeader) – -
parent_header(MsgHeader | None) – -
metadata(dict[str, Any]) – -
content(T | Content) – -
buffers(list[bytearray | bytes]) –
Source code in src/async_kernel/typing.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
Job
¶
A Message bundle.
-
Reference
-
kernel
Kernel-
comm_close -
comm_info_request -
comm_msg -
comm_open -
complete_request -
create_subshell_request -
debug_request -
delete_subshell_request -
execute_request -
get_run_mode -
history_request -
inspect_request -
interrupt_request -
is_complete_request -
kernel_info_request -
list_subshell_request -
msg_handler -
run_handler -
shutdown_request
-
-
typing
HandlerType - utils
-
kernel
Attributes:
-
msg(Message[T]) –The message received over the socket.
-
ident(bytes | list[bytes]) –The ident associated with the message and its origin.
-
received_time(float) –The time the message was received.
Source code in src/async_kernel/typing.py
314 315 316 317 318 319 320 321 322 323 324 | |
ExecuteContent
¶
Bases: TypedDict
Ref.
Attributes:
-
code(str) –The code to execute.
-
silent(bool) – -
store_history(bool) – -
user_expressions(dict[str, str]) – -
allow_stdin(bool) – -
stop_on_error(bool) –
Source code in src/async_kernel/typing.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
FixedCreate
¶
A TypedDict relevant to Fixed.
Attributes:
Source code in src/async_kernel/typing.py
344 345 346 347 348 349 350 | |
FixedCreated
¶
CallerCreateOptions
¶
Bases: TypedDict
Options to use when creating an instance of a Caller.
Attributes:
-
name(NotRequired[str]) –The name for the new caller instance.
-
log(NotRequired[LoggerAdapter]) –A logging adapter to use for the caller.
-
backend(NotRequired[Backend | Literal['trio', 'asyncio']]) –The backend to specify when calling anyio.run.
-
backend_options(NotRequired[dict | None]) –Options to pass when calling anyio.run.
-
protected(NotRequired[bool]) –The caller should be protected against accidental closure (default=
False). -
zmq_context(NotRequired[Context[Any]]) –A zmq Context to use.
Source code in src/async_kernel/typing.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
backend
instance-attribute
¶
backend: NotRequired[Backend | Literal['trio', 'asyncio']]
The backend to specify when calling anyio.run.
backend_options
instance-attribute
¶
backend_options: NotRequired[dict | None]
Options to pass when calling anyio.run.
protected
instance-attribute
¶
protected: NotRequired[bool]
The caller should be protected against accidental closure (default=False).