Internals

Initialization

IJulia.initFunction
init(args)

Initialize a kernel. args may either be empty or have one element containing the path to an existing connection file. If args is empty a connection file will be generated.

source

Cell execution hooks

IJulia.pop_posterror_hookFunction
pop_posterror_hook(f::Function)

Remove a function f() from the list of functions to execute after an error occurs when a notebook cell is evaluated.

source
IJulia.pop_postexecute_hookFunction
pop_postexecute_hook(f::Function)

Remove a function f() from the list of functions to execute after executing any notebook cell.

source
IJulia.pop_preexecute_hookFunction
pop_preexecute_hook(f::Function)

Remove a function f() from the list of functions to execute before executing any notebook cell.

source
IJulia.push_posterror_hookFunction
pop_posterror_hook(f::Function)

Remove a function f() from the list of functions to execute after an error occurs when a notebook cell is evaluated.

source
IJulia.push_postexecute_hookFunction
push_postexecute_hook(f::Function)

Push a function f() onto the end of a list of functions to execute after executing any notebook cell.

source
IJulia.push_preexecute_hookFunction
push_preexecute_hook(f::Function)

Push a function f() onto the end of a list of functions to execute before executing any notebook cell.

source

Messaging

IJulia.set_cur_msgFunction

Jupyter associates cells with message headers. Once a cell's execution state has been set as to idle, it will silently drop stream messages (i.e. output to stdout and stderr) - see https://github.com/jupyter/notebook/issues/518. When using Interact, and a widget's state changes, a new message header is sent to the IJulia kernel, and while Reactive is updating Signal graph state, it's execution state is busy, meaning Jupyter will not drop stream messages if Interact can set the header message under which the stream messages will be sent. Hence the need for this function.

source
IJulia.send_statusFunction
send_status(state::AbstractString, parent_msg::Msg=execute_msg)

Publish a status message.

source

Request handlers

Event loop

IJulia.waitloopFunction
waitloop()

Main loop of a kernel. Runs the event loops for the control and shell sockets (note: in IJulia the shell socket is called requests).

source

IO

IJulia.IJuliaStdioType

Wrapper type around redirected stdio streams, both for overloading things like flush and so that we can set properties like color.

source
IJulia.capture_stdoutConstant

The IJulia kernel captures all stdout and stderr output and redirects it to the notebook. When debugging IJulia problems, however, it can be more convenient to not capture stdout and stderr output (since the notebook may not be functioning). This can be done by editing IJulia.jl to set capture_stderr and/or capture_stdout to false.

source
IJulia.capture_stderrConstant

The IJulia kernel captures all stdout and stderr output and redirects it to the notebook. When debugging IJulia problems, however, it can be more convenient to not capture stdout and stderr output (since the notebook may not be functioning). This can be done by editing IJulia.jl to set capture_stderr and/or capture_stdout to false.

source
IJulia.watch_streamFunction
watch_stream(rd::IO, name::AbstractString)

Continually read from (size limited) Libuv/OS buffer into an IObuffer to avoid problems when the Libuv/OS buffer gets full (https://github.com/JuliaLang/julia/issues/8789). Send data immediately when buffer contains more than max_bytes bytes. Otherwise, if data is available it will be sent every stream_interval seconds (see the Timer's set up in watch_stdio). Truncate the output to max_output_per_request bytes per execution request since excessive output can bring browsers to a grinding halt.

source

Multimedia display

IJulia.ipy_mimeConstant

Supported MIME types for inline display in IPython, in descending order of preference (descending "richness").

source
IJulia.ijulia_mime_typesConstant

A vector of MIME types (or vectors of MIME types) that IJulia will try to render. IJulia will try to render every MIME type specified in the first level of the vector. If a vector of MIME types is specified, IJulia will include only the first MIME type that is renderable (this allows for the expression of priority and exclusion of redundant data).

For example, since "text/plain" is specified as a first-child of the array, IJulia will always try to include a "text/plain" representation of anything that is displayed. Since markdown and html are specified within a sub-vector, IJulia will always try to render "text/markdown", and will only try to render "text/html" if markdown isn't possible.

source
IJulia.ijulia_jsonmime_typesConstant

MIME types that when rendered (via stringmime) return JSON data. See ijulia_mime_types for a description of how MIME types are selected.

This is necessary to embed the JSON as is in the displaydata bundle (rather than as stringify'd JSON).

source
IJulia.limitstringmimeFunction
limitstringmime(mime::MIME, x, forcetext=false)

Convert x to a string of type mime, making sure to use an IOContext that tells the underlying show function to limit output.

source
IJulia.israwtextFunction

Need special handling for showing a string as a textmime type, since in that case the string is assumed to be raw data unless it is text/plain.

source
IJulia.display_dictFunction

Generate a dictionary of mime_type => data pairs for all registered MIME types. This is the format that Jupyter expects in display_data and execute_result messages.

source
IJulia.display_mimejsonFunction

Generate the preferred json-MIME representation of x.

Returns a tuple with the selected MIME type and the representation of the data using that MIME type (as a JSONText).

source
IJulia.display_mimestringFunction

Generate the preferred MIME representation of x.

Returns a tuple with the selected MIME type and the representation of the data using that MIME type.

source
IJulia.register_mimeFunction
register_mime(x::Union{MIME, Vector{MIME}})
register_mime(x::AbstractVector{<:MIME})

Register a new MIME type.

source
IJulia.register_jsonmimeFunction
register_jsonmime(x::Union{MIME, Vector{MIME}})
register_jsonmime(x::AbstractVector{<:MIME})

Register a new JSON MIME type.

source

Jupyter

IJulia.find_jupyter_subcommandFunction
find_jupyter_subcommand(subcommand::AbstractString, port::Union{Nothing,Int}=nothing)

Return a Cmd for the program subcommand. If the program is jupyter or jupyterlab it may prompt the user to install it.

source
IJulia.launchFunction
launch(cmd, dir, detached)

Run cmd in dir. If detached is false it will not wait for the command to finish.

source

Debugging

IJulia.set_verboseFunction
set_verbose(v=true)

This function enables (or disables, for set_verbose(false)) verbose output from the IJulia kernel, when called within a running notebook. This consists of log messages printed to the terminal window where jupyter was launched, displaying information about every message sent or received by the kernel. Used for debugging IJulia.

source

Utility

IJulia.num_utf8_trailingFunction

If d ends with an incomplete UTF8-encoded character, return the number of trailing incomplete bytes. Otherwise, return 0.

source