interface
Modules:
-
base–The interface class definition which provides configuration, access to the kernel and connections.
-
callable– -
ip_app–An IPython application with a zmq interface.
Classes:
-
HasInterface–A mixin class providing a reference to the global interface.
-
Interface–The base class for kernel interface (singleton).
Functions:
-
start_kernel_callable_interface–Start the interface using functions for passing serialised messages.
-
launch_interface–Launch a kernel interface blocking until it has stopped.
HasInterface
¶
Bases: Generic[T_interface_co]
A mixin class providing a reference to the global interface.
This class is designed to be compatible with Configurable objects enabling the sharing of configuration and log objects. The global interface must exist before creating subclass instances using this mixin.
Attributes:
-
parent(T_interface_co) –The interface at the time of creation.
-
config(Config) –A reference to the
parent.config.
Source code in src/async_kernel/interface/base.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
Interface
¶
Bases: StartStopTask, Application, Generic[T_shell_co]
The base class for kernel interface (singleton).
The interface creates the kernel and provides external communication. It is also
the parent object for all objects that subclass from HasInterface. Configurable
objects that subclass from HasInterface inherit their configuration from the
interface (Application).
Usage
launch:
Interface.launch_instance()
async with Interface().start() as interface:
interface.kernel
...
app = Interface().start()
- Reference
Methods:
-
initialized–Has an instance been created?
-
instance–Get the singleton instance that was created using
launch_instance. -
initialize–Initialize the interface DO NOT CALL DIRECTLY.
-
start–Start the interface in one of two modes depending if there is a running event loop.
-
interface_task–The main task to run the kernel and open connections.
-
update_connections–Update the list of connections.
-
input_request–Request input from the client given the current context.
-
iopub_send–Publish an iopub message on all connections.
-
get_connection_info–Ruturns a list of strings for connection details of each active connection which provides it.
Attributes:
-
kernel_name–The kernel's name.
-
classes(ClassesType) –The classes registered with the interface.
-
aliases(dict[str | tuple[str, ...], str]) – -
flags– -
host(TraitType[Hosts | None, Hosts | None]) –The name of a (gui) event loop (if one is used).
-
host_options–Options for starting the loop.
-
backend(TraitType[Backend, Backend]) –The type of asynchronous backend used. Options are 'asyncio' or 'trio'.
-
backend_options–Options for starting the backend.
-
interface_class(Type[type[Self], type[Self] | str]) –The interface class to use when launching.
-
kernel_class(Type[type[Kernel[Self, T_shell_co]], type[Kernel[Self, T_shell_co]] | str]) –The Kernel class to use when creating the kernel.
-
shell_class(Type[type[T_shell_co], type[T_shell_co] | str]) –The class to use for shells and subshells.
-
quiet–Only send stdout/stderr to output stream.
-
launcher–The value used to import the interface using async_kernel.kernelspec.import_launcher.
-
force_shutdown_delay–The time in seconds to wait after stop is called before stop with force enabled is called.
-
callers(Fixed[Self, dict[Literal[shell, control], Caller]]) –The callers used by the messaging application.
-
kernel(Fixed[Self, Kernel[Self, T_shell_co]]) –The kernel is defines the request handlers and handles incoming jobs (message requests).
-
comm_manager(Fixed[Self, CommManager]) –The global comm manager.
-
autostart_connections–A list of connections to start with the app.
-
shell(Fixed[Self, T_shell_co]) –The main shell.
-
summary(str) –Summary info about the interface.
-
connections(tuple[Connection[Self], ...]) –The connections currently registered with the interface.
Source code in src/async_kernel/interface/base.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 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
kernel_name
class-attribute
instance-attribute
¶
kernel_name = traitlets.Unicode('async').tag(config=True)
The kernel's name.
classes
class-attribute
instance-attribute
¶
classes: ClassesType = final([])
The classes registered with the interface.
aliases
class-attribute
instance-attribute
¶
aliases: dict[str | tuple[str, ...], str] = (
Application.aliases
| {
("name", "n"): "Interface.kernel_name",
("f", "connection_file"): "ZMQMessage.connection_file",
"launcher": "Interface.launcher",
"timeout": "BaseShell.timeout",
"kernel_class": "Interface.kernel_class",
"shell_class": "Interface.shell_class",
"help_links": "Kernel.help_links",
"supported_features": "Kernel.supported_features",
"interface_class": "Interface.interface_class",
"host": "Interface.host",
"host_options": "Interface.host_options",
"backend_options": "Interface.backend_options",
"backend": "Interface.backend",
}
| Application.aliases
)
flags
class-attribute
instance-attribute
¶
flags = {
"quiet": (
{"Interface": {"quiet": True}},
"Only send stdout/stderr to output stream.",
),
"no-quiet": (
{"Interface": {"quiet": False}},
"Only send stdout/stderr to output stream.",
),
} | Application.flags
host
class-attribute
instance-attribute
¶
host: TraitType[Hosts | None, Hosts | None] = traitlets.UseEnum(
Hosts, default_value=None, allow_none=True
).tag(config=True)
The name of a (gui) event loop (if one is used).
host_options
class-attribute
instance-attribute
¶
host_options = DictValueLiteralEval(allow_none=True).tag(config=True)
Options for starting the loop.
backend
class-attribute
instance-attribute
¶
The type of asynchronous backend used. Options are 'asyncio' or 'trio'.
backend_options
class-attribute
instance-attribute
¶
backend_options = DictValueLiteralEval(allow_none=True).tag(config=True)
Options for starting the backend.
interface_class
class-attribute
instance-attribute
¶
interface_class: Type[type[Self], type[Self] | str] = traitlets.Type(
"async_kernel.interface.base.Interface"
).tag(config=True)
The interface class to use when launching.
kernel_class
class-attribute
instance-attribute
¶
kernel_class: Type[
type[Kernel[Self, T_shell_co]], type[Kernel[Self, T_shell_co]] | str
] = traitlets.Type("async_kernel.Kernel").tag(config=True)
The Kernel class to use when creating the kernel.
shell_class
class-attribute
instance-attribute
¶
shell_class: Type[type[T_shell_co], type[T_shell_co] | str] = traitlets.Type(
"async_kernel.shell.ipshell.IPShell", "async_kernel.shell.BaseShell"
).tag(config=True)
The class to use for shells and subshells.
quiet
class-attribute
instance-attribute
¶
quiet = traitlets.Bool(True).tag(config=True)
Only send stdout/stderr to output stream.
launcher
class-attribute
instance-attribute
¶
launcher = traitlets.Unicode('').tag(config=True)
The value used to import the interface using async_kernel.kernelspec.import_launcher.
force_shutdown_delay
class-attribute
instance-attribute
¶
The time in seconds to wait after stop is called before stop with force enabled is called.
callers
class-attribute
instance-attribute
¶
callers: Fixed[Self, dict[Literal[shell, control], Caller]] = Fixed(
lambda c: {
Channel.shell: c["owner"].caller,
Channel.control: c["owner"].caller.get(name="Control"),
}
)
The callers used by the messaging application.
kernel
class-attribute
instance-attribute
¶
kernel: Fixed[Self, Kernel[Self, T_shell_co]] = Fixed(
lambda c: c["owner"].kernel_class(c["owner"], c["owner"].shell_class)
)
The kernel is defines the request handlers and handles incoming jobs (message requests).
comm_manager
class-attribute
instance-attribute
¶
The global comm manager.
autostart_connections
class-attribute
instance-attribute
¶
autostart_connections = traitlets.List().tag(config=True)
A list of connections to start with the app.
shell
class-attribute
instance-attribute
¶
The main shell.
connections
property
¶
connections: tuple[Connection[Self], ...]
The connections currently registered with the interface.
Depending on the type of connection there could be zero or more clients connected.
- Connection: There is a 1-1 connection client ratio for a LocalCient.
- ZMQConnection: There can be 0+ connected ZMQClients.
initialized
classmethod
¶
initialized() -> bool
Has an instance been created?
Source code in src/async_kernel/interface/base.py
233 234 235 236 237 | |
instance
classmethod
¶
instance() -> T_interface_co
Get the singleton instance that was created using launch_instance.
Source code in src/async_kernel/interface/base.py
239 240 241 242 243 244 245 246 247 248 249 | |
initialize
¶
Initialize the interface DO NOT CALL DIRECTLY.
Source code in src/async_kernel/interface/base.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
start
¶
start() -> Self
Start the interface in one of two modes depending if there is a running event loop.
- Non-blocking: If there is a running event loop (asyncio or trio) this will schedule the interface to start.
- Blocking: If there is no running event loop.
Warning
- Running in a thread other than the 'MainThread' is permitted, but discouraged.
- Blocking calls can only be interrupted in the 'MainThread' because 'threads cannot be destroyed, stopped, suspended, resumed, or interrupted'.
- Some libraries may assume the call is occurring in the 'MainThread'.
- If there is an
asyncioortrioevent loop already running in the desired thread; start asynchronously instead (async with interface: ...).
Source code in src/async_kernel/interface/base.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
interface_task
async
¶
The main task to run the kernel and open connections.
Source code in src/async_kernel/interface/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
update_connections
¶
update_connections(*new: Connection[Self]) -> None
Update the list of connections.
Parameters:
-
(new¶Connection[Self], default:()) –new connections to add.
Source code in src/async_kernel/interface/base.py
422 423 424 425 426 427 428 429 430 431 432 433 | |
input_request
¶
Request input from the client given the current context.
Parameters:
-
(prompt¶str) –The prompt to display.
-
(password¶bool, default:False) –If the prompt should be treated visually as a password.
Raises:
-
RuntimeError–If there is no active job in the current context.
Source code in src/async_kernel/interface/base.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
iopub_send
¶
iopub_send(
msg_type: IOPubMsgTypeAlias | str,
content: Content | None = None,
*,
metadata: dict[str, Any] | None = None,
parent: dict[str, Any] | MsgHeader | NoValue | None = NoValue,
ident: bytes | list[bytes] | None = None,
buffers: BuffersType | None = None,
) -> None
Publish an iopub message on all connections.
Source code in src/async_kernel/interface/base.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
get_connection_info
¶
Ruturns a list of strings for connection details of each active connection which provides it.
Source code in src/async_kernel/interface/base.py
499 500 501 | |
start_kernel_callable_interface
async
¶
start_kernel_callable_interface(
*,
send: Callable[[T, BuffersType, bool], Any],
stopped: Callable[[], Any],
settings: dict | None = None,
pack_unpack: tuple[Callable[[Message], T], Callable[[T], Message]] = (
pack_json_str,
unpack_json,
),
) -> Handlers[T]
Start the interface using functions for passing serialised messages.
Parameters:
-
(send¶Callable[[T, BuffersType, bool], Any]) –A function for the interface to send the packed message.
-
(stopped¶Callable[[], Any]) –A callback that is called when the interface has stopped.
-
(settings¶dict | None, default:None) –Additional settings to configure the interface/kernel/shell etc using traitlets config conventions. The settings are converted to argv using async_kernel.kernelspec.make_argv. All settings, including aliases and flags are accepted. flags should be passed as
'flags': [<flag1>, <flag2>, ...]. -
(pack_unpack¶tuple[Callable[[Message], T], Callable[[T], Message]], default:(pack_json_str, unpack_json)) –A pair of methods to serialize and unserialize messages.
Returns: The connection instance.
Source code in src/async_kernel/interface/callable.py
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 | |
launch_interface
¶
launch_interface(settings: dict) -> None
Launch a kernel interface blocking until it has stopped.
Notes
- Available in CPython.
- 'interface_class' can be specified in settings as a subclass of Interface or as an importable string.
settingsare NOT loaded.sys.argvis used for configuration. Useasync-kernel --help-allto see all configuration options.- traitlets configuration documentation.
Source code in src/async_kernel/interface/__init__.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
The interface class definition which provides configuration, access to the kernel and connections.
Classes:
-
Interface–The base class for kernel interface (singleton).
-
HasInterface–A mixin class providing a reference to the global interface.
Interface
¶
Bases: StartStopTask, Application, Generic[T_shell_co]
The base class for kernel interface (singleton).
The interface creates the kernel and provides external communication. It is also
the parent object for all objects that subclass from HasInterface. Configurable
objects that subclass from HasInterface inherit their configuration from the
interface (Application).
Usage
launch:
Interface.launch_instance()
async with Interface().start() as interface:
interface.kernel
...
app = Interface().start()
- Reference
Methods:
-
initialized–Has an instance been created?
-
instance–Get the singleton instance that was created using
launch_instance. -
initialize–Initialize the interface DO NOT CALL DIRECTLY.
-
start–Start the interface in one of two modes depending if there is a running event loop.
-
interface_task–The main task to run the kernel and open connections.
-
update_connections–Update the list of connections.
-
input_request–Request input from the client given the current context.
-
iopub_send–Publish an iopub message on all connections.
-
get_connection_info–Ruturns a list of strings for connection details of each active connection which provides it.
Attributes:
-
kernel_name–The kernel's name.
-
classes(ClassesType) –The classes registered with the interface.
-
aliases(dict[str | tuple[str, ...], str]) – -
flags– -
host(TraitType[Hosts | None, Hosts | None]) –The name of a (gui) event loop (if one is used).
-
host_options–Options for starting the loop.
-
backend(TraitType[Backend, Backend]) –The type of asynchronous backend used. Options are 'asyncio' or 'trio'.
-
backend_options–Options for starting the backend.
-
interface_class(Type[type[Self], type[Self] | str]) –The interface class to use when launching.
-
kernel_class(Type[type[Kernel[Self, T_shell_co]], type[Kernel[Self, T_shell_co]] | str]) –The Kernel class to use when creating the kernel.
-
shell_class(Type[type[T_shell_co], type[T_shell_co] | str]) –The class to use for shells and subshells.
-
quiet–Only send stdout/stderr to output stream.
-
launcher–The value used to import the interface using async_kernel.kernelspec.import_launcher.
-
force_shutdown_delay–The time in seconds to wait after stop is called before stop with force enabled is called.
-
callers(Fixed[Self, dict[Literal[shell, control], Caller]]) –The callers used by the messaging application.
-
kernel(Fixed[Self, Kernel[Self, T_shell_co]]) –The kernel is defines the request handlers and handles incoming jobs (message requests).
-
comm_manager(Fixed[Self, CommManager]) –The global comm manager.
-
autostart_connections–A list of connections to start with the app.
-
shell(Fixed[Self, T_shell_co]) –The main shell.
-
summary(str) –Summary info about the interface.
-
connections(tuple[Connection[Self], ...]) –The connections currently registered with the interface.
Source code in src/async_kernel/interface/base.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 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
kernel_name
class-attribute
instance-attribute
¶
kernel_name = traitlets.Unicode('async').tag(config=True)
The kernel's name.
classes
class-attribute
instance-attribute
¶
classes: ClassesType = final([])
The classes registered with the interface.
aliases
class-attribute
instance-attribute
¶
aliases: dict[str | tuple[str, ...], str] = (
Application.aliases
| {
("name", "n"): "Interface.kernel_name",
("f", "connection_file"): "ZMQMessage.connection_file",
"launcher": "Interface.launcher",
"timeout": "BaseShell.timeout",
"kernel_class": "Interface.kernel_class",
"shell_class": "Interface.shell_class",
"help_links": "Kernel.help_links",
"supported_features": "Kernel.supported_features",
"interface_class": "Interface.interface_class",
"host": "Interface.host",
"host_options": "Interface.host_options",
"backend_options": "Interface.backend_options",
"backend": "Interface.backend",
}
| Application.aliases
)
flags
class-attribute
instance-attribute
¶
flags = {
"quiet": (
{"Interface": {"quiet": True}},
"Only send stdout/stderr to output stream.",
),
"no-quiet": (
{"Interface": {"quiet": False}},
"Only send stdout/stderr to output stream.",
),
} | Application.flags
host
class-attribute
instance-attribute
¶
host: TraitType[Hosts | None, Hosts | None] = traitlets.UseEnum(
Hosts, default_value=None, allow_none=True
).tag(config=True)
The name of a (gui) event loop (if one is used).
host_options
class-attribute
instance-attribute
¶
host_options = DictValueLiteralEval(allow_none=True).tag(config=True)
Options for starting the loop.
backend
class-attribute
instance-attribute
¶
The type of asynchronous backend used. Options are 'asyncio' or 'trio'.
backend_options
class-attribute
instance-attribute
¶
backend_options = DictValueLiteralEval(allow_none=True).tag(config=True)
Options for starting the backend.
interface_class
class-attribute
instance-attribute
¶
interface_class: Type[type[Self], type[Self] | str] = traitlets.Type(
"async_kernel.interface.base.Interface"
).tag(config=True)
The interface class to use when launching.
kernel_class
class-attribute
instance-attribute
¶
kernel_class: Type[
type[Kernel[Self, T_shell_co]], type[Kernel[Self, T_shell_co]] | str
] = traitlets.Type("async_kernel.Kernel").tag(config=True)
The Kernel class to use when creating the kernel.
shell_class
class-attribute
instance-attribute
¶
shell_class: Type[type[T_shell_co], type[T_shell_co] | str] = traitlets.Type(
"async_kernel.shell.ipshell.IPShell", "async_kernel.shell.BaseShell"
).tag(config=True)
The class to use for shells and subshells.
quiet
class-attribute
instance-attribute
¶
quiet = traitlets.Bool(True).tag(config=True)
Only send stdout/stderr to output stream.
launcher
class-attribute
instance-attribute
¶
launcher = traitlets.Unicode('').tag(config=True)
The value used to import the interface using async_kernel.kernelspec.import_launcher.
force_shutdown_delay
class-attribute
instance-attribute
¶
The time in seconds to wait after stop is called before stop with force enabled is called.
callers
class-attribute
instance-attribute
¶
callers: Fixed[Self, dict[Literal[shell, control], Caller]] = Fixed(
lambda c: {
Channel.shell: c["owner"].caller,
Channel.control: c["owner"].caller.get(name="Control"),
}
)
The callers used by the messaging application.
kernel
class-attribute
instance-attribute
¶
kernel: Fixed[Self, Kernel[Self, T_shell_co]] = Fixed(
lambda c: c["owner"].kernel_class(c["owner"], c["owner"].shell_class)
)
The kernel is defines the request handlers and handles incoming jobs (message requests).
comm_manager
class-attribute
instance-attribute
¶
The global comm manager.
autostart_connections
class-attribute
instance-attribute
¶
autostart_connections = traitlets.List().tag(config=True)
A list of connections to start with the app.
shell
class-attribute
instance-attribute
¶
The main shell.
connections
property
¶
connections: tuple[Connection[Self], ...]
The connections currently registered with the interface.
Depending on the type of connection there could be zero or more clients connected.
- Connection: There is a 1-1 connection client ratio for a LocalCient.
- ZMQConnection: There can be 0+ connected ZMQClients.
initialized
classmethod
¶
initialized() -> bool
Has an instance been created?
Source code in src/async_kernel/interface/base.py
233 234 235 236 237 | |
instance
classmethod
¶
instance() -> T_interface_co
Get the singleton instance that was created using launch_instance.
Source code in src/async_kernel/interface/base.py
239 240 241 242 243 244 245 246 247 248 249 | |
initialize
¶
Initialize the interface DO NOT CALL DIRECTLY.
Source code in src/async_kernel/interface/base.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
start
¶
start() -> Self
Start the interface in one of two modes depending if there is a running event loop.
- Non-blocking: If there is a running event loop (asyncio or trio) this will schedule the interface to start.
- Blocking: If there is no running event loop.
Warning
- Running in a thread other than the 'MainThread' is permitted, but discouraged.
- Blocking calls can only be interrupted in the 'MainThread' because 'threads cannot be destroyed, stopped, suspended, resumed, or interrupted'.
- Some libraries may assume the call is occurring in the 'MainThread'.
- If there is an
asyncioortrioevent loop already running in the desired thread; start asynchronously instead (async with interface: ...).
Source code in src/async_kernel/interface/base.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
interface_task
async
¶
The main task to run the kernel and open connections.
Source code in src/async_kernel/interface/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
update_connections
¶
update_connections(*new: Connection[Self]) -> None
Update the list of connections.
Parameters:
-
(new¶Connection[Self], default:()) –new connections to add.
Source code in src/async_kernel/interface/base.py
422 423 424 425 426 427 428 429 430 431 432 433 | |
input_request
¶
Request input from the client given the current context.
Parameters:
-
(prompt¶str) –The prompt to display.
-
(password¶bool, default:False) –If the prompt should be treated visually as a password.
Raises:
-
RuntimeError–If there is no active job in the current context.
Source code in src/async_kernel/interface/base.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
iopub_send
¶
iopub_send(
msg_type: IOPubMsgTypeAlias | str,
content: Content | None = None,
*,
metadata: dict[str, Any] | None = None,
parent: dict[str, Any] | MsgHeader | NoValue | None = NoValue,
ident: bytes | list[bytes] | None = None,
buffers: BuffersType | None = None,
) -> None
Publish an iopub message on all connections.
Source code in src/async_kernel/interface/base.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
get_connection_info
¶
Ruturns a list of strings for connection details of each active connection which provides it.
Source code in src/async_kernel/interface/base.py
499 500 501 | |
HasInterface
¶
Bases: Generic[T_interface_co]
A mixin class providing a reference to the global interface.
This class is designed to be compatible with Configurable objects enabling the sharing of configuration and log objects. The global interface must exist before creating subclass instances using this mixin.
Attributes:
-
parent(T_interface_co) –The interface at the time of creation.
-
config(Config) –A reference to the
parent.config.
Source code in src/async_kernel/interface/base.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
An IPython application with a zmq interface.
Classes:
-
IPApp–An IPython application with a zmq interface.
IPApp
¶
Bases: Interface[T_ipshell_co], BaseIPythonApplication, InteractiveShellApp, Generic[T_ipshell_co]
An IPython application with a zmq interface.
Attributes:
-
description–A description to use for the command line interface.
-
aliases– -
flags–
Source code in src/async_kernel/interface/ip_app.py
22 23 24 25 26 27 28 29 30 31 32 33 34 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 | |
description
class-attribute
instance-attribute
¶
description = traitlets.Unicode(
"async-kernel: A Jupyter kernel providing an asynchronous IPython shell."
).tag(config=True)
A description to use for the command line interface.
aliases
class-attribute
instance-attribute
¶
aliases = (
Interface.aliases
| {
"profile-dir": "ProfileDir.location",
"profile": "BaseIPythonApplication.profile",
"ipython-dir": "BaseIPythonApplication.ipython_dir",
"config": "BaseIPythonApplication.extra_config_file",
}
| shell_aliases
)
flags
class-attribute
instance-attribute
¶
flags = (
Interface.flags
| {
"automagic": (
{"InteractiveShell": {"automagic": True}},
"Turn on the auto calling of magic commands. Type %%magic at the IPython prompt for more information.",
),
"no-automagic": (
{"InteractiveShell": {"automagic": False}},
"Turn off the auto calling of magic commands.",
),
}
| shell_flags
)