@jupyterlite

***`

@jupyterlite / @jupyterlite/kernel / BaseKernel

Class: ``abstract BaseKernel#

Defined in: packages/kernel/src/base.ts:10

A base kernel class handling basic kernel messaging.

Implements#

Constructors#

Constructor#

**new BaseKernel**(options): BaseKernel

Defined in: packages/kernel/src/base.ts:16

Construct a new BaseKernel.

Parameters#

options#

IOptions

The instantiation options for a BaseKernel.

Returns#

BaseKernel

Accessors#

disposed#

Get Signature#

**get** **disposed**(): ISignal<this, void>

Defined in: packages/kernel/src/base.ts:41

A signal emitted when the kernel is disposed.

Returns#

ISignal<this, void>

A signal emitted when the object is disposed.

Implementation of#

IKernel.disposed

`***

executionCount#

Get Signature#

get executionCount(): number

Defined in: packages/kernel/src/base.ts:69

The current execution count

Returns#

number

***`

id#

Get Signature#

**get** **id**(): string

Defined in: packages/kernel/src/base.ts:48

Get the kernel id

Returns#

string

The id of the server-side kernel.

Implementation of#

IKernel.id

`***

isDisposed#

Get Signature#

get isDisposed(): boolean

Defined in: packages/kernel/src/base.ts:34

Return whether the kernel is disposed.

Returns#

boolean

Test whether the object has been disposed.

Notes#

This property is always safe to access.

Implementation of#

IKernel.isDisposed

***`

location#

Get Signature#

**get** **location**(): string

Defined in: packages/kernel/src/base.ts:62

The location in the virtual filesystem from which the kernel was started.

Returns#

string

The location in the virtual filesystem from which the kernel was started.

Implementation of#

IKernel.location

`***

name#

Get Signature#

get name(): string

Defined in: packages/kernel/src/base.ts:55

Get the name of the kernel

Returns#

string

The name of the server-side kernel.

Implementation of#

IKernel.name

***`

parent#

Get Signature#

**get** **parent**(): undefined | IMessage<MessageType>

Defined in: packages/kernel/src/base.ts:83

Get the last parent message (mimic ipykernel’s get_parent)

Returns#

undefined | IMessage<MessageType>

`***

parentHeader#

Get Signature#

get parentHeader(): undefined | IHeader<MessageType>

Defined in: packages/kernel/src/base.ts:76

Get the last parent header

Returns#

undefined | IHeader<MessageType>

***`

ready#

Get Signature#

**get** **ready**(): Promise<void>

Defined in: packages/kernel/src/base.ts:27

A promise that is fulfilled when the kernel is ready.

Returns#

Promise<void>

A promise that is fulfilled when the kernel is ready.

Implementation of#

IKernel.ready

Methods#

clearOutput()#

protected **clearOutput**(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:392

Send a clear_output message to the client.

Parameters#

content#

The clear_output content.

wait#

boolean

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

`***

commClose()#

abstract commClose(msg): Promise<void>

Defined in: packages/kernel/src/base.ts:231

Send an comm_close message.

Parameters#

msg#

ICommCloseMsg

Returns#

Promise<void>

***`

commInfoRequest()#

abstract **commInfoRequest**(content): Promise<ReplyContent<ICommInfoReply>>

Defined in: packages/kernel/src/base.ts:201

Handle a comm_info_request message.

Parameters#

content#

The content of the request.

target_name?#

string

The comm target name to filter returned comms

Returns#

Promise<ReplyContent<ICommInfoReply>>

A promise that resolves with the response message.

`***

commMsg()#

abstract commMsg(msg): Promise<void>

Defined in: packages/kernel/src/base.ts:224

Send an comm_msg message.

Parameters#

msg#

ICommMsgMsg

The comm_msg message.

Returns#

Promise<void>

***`

commOpen()#

abstract **commOpen**(msg): Promise<void>

Defined in: packages/kernel/src/base.ts:217

Send an comm_open message.

Parameters#

msg#

ICommOpenMsg

The comm_open message.

Returns#

Promise<void>

`***

completeRequest()#

abstract completeRequest(content): Promise<ReplyContent<ICompleteReply>>

Defined in: packages/kernel/src/base.ts:168

Handle a complete_request message.

Parameters#

content#

The content of the request.

code#

string

cursor_pos#

number

Returns#

Promise<ReplyContent<ICompleteReply>>

***`

displayData()#

protected **displayData**(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:264

Send a display_data message to the client.

Parameters#

content#

The display_data content.

data#

IMimeBundle

metadata#

PartialJSONObject

transient?#

{ display_id: string; }

transient.display_id?#

string

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

`***

dispose()#

dispose(): void

Defined in: packages/kernel/src/base.ts:90

Dispose the kernel.

Returns#

void

Implementation of#

IKernel.dispose

***`

executeRequest()#

abstract **executeRequest**(content): Promise<ReplyContent<IExecuteReply> & IExecuteCount>

Defined in: packages/kernel/src/base.ts:159

Handle an execute_request message.

Parameters#

content#

The content of the execute_request kernel message

allow_stdin?#

boolean

Whether to allow stdin requests. The default is true.

code#

string

The code to execute.

silent?#

boolean

Whether to execute the code as quietly as possible. The default is false.

stop_on_error?#

boolean

Whether to the abort execution queue on an error. The default is false.

store_history?#

boolean

Whether to store history of the execution. The default true if silent is False. It is forced to false if silent is true.

user_expressions?#

JSONObject

A mapping of names to expressions to be evaluated in the kernel’s interactive namespace.

Returns#

Promise<ReplyContent<IExecuteReply> & IExecuteCount>

`***

handleComm()#

protected handleComm(type, content, metadata, buffers, parentHeader): void

Defined in: packages/kernel/src/base.ts:416

Send a comm message to the client.

Parameters#

type#

"comm_close" | "comm_msg" | "comm_open"

content#
comm_id#

string

data#

JSONObject

metadata#

JSONObject

buffers#

undefined | (ArrayBuffer | ArrayBufferView)[]

parentHeader#

undefined | IHeader<MessageType>

Returns#

void

***`

handleMessage()#

**handleMessage**(msg): Promise<void>

Defined in: packages/kernel/src/base.ts:103

Handle an incoming message from the client.

Parameters#

msg#

IMessage

The message to handle

Returns#

Promise<void>

Implementation of#

IKernel.handleMessage

`***

inputReply()#

abstract inputReply(content): void

Defined in: packages/kernel/src/base.ts:210

Send an input_reply message.

Parameters#

content#

ReplyContent<IInputReply>

The content of the reply.

Returns#

void

***`

inputRequest()#

protected **inputRequest**(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:292

Send a input_request message to the client.

Parameters#

content#

The input_request content.

password#

boolean

Whether the request is for a password. If so, the frontend shouldn’t echo input.

prompt#

string

The text to show at the prompt.

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

`***

inspectRequest()#

abstract inspectRequest(content): Promise<ReplyContent<IInspectReply>>

Defined in: packages/kernel/src/base.ts:179

Handle an inspect_request message.

Parameters#

content#

The content of the request.

code#

string

cursor_pos#

number

detail_level#

0 | 1

Returns#

Promise<ReplyContent<IInspectReply>>

A promise that resolves with the response message.

***`

isCompleteRequest()#

abstract **isCompleteRequest**(content): Promise<ReplyContent<IIsCompleteReplyIncomplete | IIsCompleteReplyOther>>

Defined in: packages/kernel/src/base.ts:190

Handle an is_complete_request message.

Parameters#

content#

The content of the request.

code#

string

Returns#

Promise<ReplyContent<IIsCompleteReplyIncomplete | IIsCompleteReplyOther>>

A promise that resolves with the response message.

`***

kernelInfoRequest()#

abstract kernelInfoRequest(): Promise<ReplyContent<IInfoReply>>

Defined in: packages/kernel/src/base.ts:152

Handle a kernel_info_request message.

Returns#

Promise<ReplyContent<IInfoReply>>

A promise that resolves with the kernel info.

***`

publishExecuteError()#

protected **publishExecuteError**(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:342

Send an error message to the client.

Parameters#

content#

The error content.

ename#

string

evalue#

string

traceback#

string[]

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

`***

publishExecuteResult()#

protected publishExecuteResult(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:317

Send an execute_result message.

Parameters#

content#

The execute result content.

data#

IMimeBundle

execution_count#

ExecutionCount

metadata#

PartialJSONObject

transient?#

{ display_id: string; }

transient.display_id?#

string

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

***`

stream()#

protected **stream**(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:239

Stream an event from the kernel

Parameters#

content#

The stream content.

name#

"stdout" | "stderr"

text#

string

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void

`***

updateDisplayData()#

protected updateDisplayData(content, parentHeader): void

Defined in: packages/kernel/src/base.ts:367

Send a update_display_data message to the client.

Parameters#

content#

object & object

The update_display_data content.

parentHeader#

The parent header.

undefined | IHeader<MessageType>

Returns#

void