An object of this class handles the low-level communication with the Jupyter frontend or kernel manager. There should only be one object of this class in existence.

Public fields

evaluator

See Evaluator.

comm_manager

See CommManagerClass.

print

This field is intended to hold the original \'print\' function from package "base"

cat

This field is intended to hold the original \'cat\' function from package "base"

str

This field is intended to hold the original \'str\' function from package "utils"

httpd

This field is intended to hold the original \'httpd\' function from package "tools"

Methods


Method new()

Initialize the kernel

Usage

Kernel$new(conn_info)

Arguments

conn_info

A list with the connection info from the front-end


Method run()

Run the kernel.

Usage

Kernel$run()


Method poll_and_respond()

A single iteration of the kernel loop

Usage

Kernel$poll_and_respond()


Method clear_output()

Clear the current output cell in the frontend.

Usage

Kernel$clear_output(wait)

Arguments

wait

Logical value, whether to wait until output is cleared.


Method stream()

Stream text to the frontend.

Usage

Kernel$stream(text, stream)

Arguments

text

Text to be sent to the frontend

stream

A string to select the stream -- either "stout" or "stderr"


Method execute_result()

Send execution results to the frontend

Usage

Kernel$execute_result(data, metadata = emptyNamedList)

Arguments

data

Execution result in rich format

metadata

A list with metadata


Method display_send()

Send rich format data to the frontend

Usage

Kernel$display_send(d)

Arguments

d

A list that is either a member of class "display_data" or "update_display_data".


Method display_data()

Send rich format data to the frontend

Usage

Kernel$display_data(data, metadata = emptyNamedList, transient = NULL)

Arguments

data

A list with mime-type members.

metadata

A named list with metadata.

transient

An optional list with the current display id.


Method update_display_data()

Update rich format data to the frontend

Usage

Kernel$update_display_data(data, metadata = emptyNamedList, transient)

Arguments

data

A list with mime-type members.

metadata

A named list with metadata.

transient

An list with the current display id.


Method send_error()

Send an error message and traceback to the frontend.

Usage

Kernel$send_error(name, value, traceback)

Arguments

name

A string, the error name.

value

A string, the value of the error message.

traceback

A character vector with the traceback.


Method send_comm_msg()

Send a message via a comm.

Usage

Kernel$send_comm_msg(id, data, metadata = emptyNamedList, buffers = NULL)

Arguments

id

A string that identifies the comm.

data

A list with data.

metadata

An optional list with metadata.

buffers

An optional list of raw vectors.


Method send_comm_open()

Open a comm in the frontend.

Usage

Kernel$send_comm_open(
  id,
  target_name,
  data,
  metadata = emptyNamedList,
  buffers = NULL
)

Arguments

id

A string that identifies the comm.

target_name

A string that identifies a group of related comms.

data

A list with data.

metadata

An optional list with metadata.

buffers

An optional list of raw vectors.


Method send_comm_close()

Close a comm in the frontend.

Usage

Kernel$send_comm_close(
  id,
  data = emptyNamedList,
  metadata = emptyNamedList,
  buffers = NULL
)

Arguments

id

A string that identifies the comm.

data

A list with data.

metadata

An optional list with metadata.

buffers

An optional list of raw vectors.


Method log_out()

Show a message in the Jupyter server log

Usage

Kernel$log_out(message, ..., use.print = FALSE, use.str = FALSE)

Arguments

message

A string or object to be shown in the log.

...

More character strings, pasted to the message.

use.print

Logical value, whether the function 'print()' should applied to the message.

use.str

Logical value, whether 'str()' should be called and its output shown


Method log_warning()

Show a warning in the Jupyter server log

Usage

Kernel$log_warning(message)

Arguments

message

A string to be shown in the log


Method log_error()

Show an error message in the Jupyter server log

Usage

Kernel$log_error(message)

Arguments

message

A string to be shown in the log


Method add_service()

Add a service to the kernel, i.e. a function that is called in each iteration of the kernel event loop.

Usage

Kernel$add_service(run, init = NULL)

Arguments

run

A function to be run in each loop iteration.

init

A function to be run once in the first iteration.


Method remove_service()

Remove a service from the kernel.

Usage

Kernel$remove_service(run)

Arguments

run

The function to be removed.


Method get_parent()

The parent of the message currently sent.

Usage

Kernel$get_parent(channel = "shell")

Arguments

channel

A string, the relevant input channel.


Method get_conn_info()

Return the current connection info.

Usage

Kernel$get_conn_info()


Method is_child()

Check if the current process is a fork from the original kernel process

Usage

Kernel$is_child()


Method input_request()

Send an input request to the frontend

Usage

Kernel$input_request(prompt = "", password = FALSE)

Arguments

prompt

A prompt string

password

Logical value; whether the input should be hidden like in a password dialog


Method read_stdin()

Read a line from the frontend

Usage

Kernel$read_stdin()


Method clone()

The objects of this class are cloneable with this method.

Usage

Kernel$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.