Internals
Initialization
IJulia.init
— Functioninit(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.
Cell execution hooks
IJulia.pop_posterror_hook
— Functionpop_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.
IJulia.pop_postexecute_hook
— Functionpop_postexecute_hook(f::Function)
Remove a function f()
from the list of functions to execute after executing any notebook cell.
IJulia.pop_preexecute_hook
— Functionpop_preexecute_hook(f::Function)
Remove a function f()
from the list of functions to execute before executing any notebook cell.
IJulia.push_posterror_hook
— Functionpop_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.
IJulia.push_postexecute_hook
— Functionpush_postexecute_hook(f::Function)
Push a function f()
onto the end of a list of functions to execute after executing any notebook cell.
IJulia.push_preexecute_hook
— Functionpush_preexecute_hook(f::Function)
Push a function f()
onto the end of a list of functions to execute before executing any notebook cell.
Messaging
IJulia.Msg
— TypeIPython message struct.
IJulia.msg_header
— Functionmsg_header(m::Msg, msg_type::String)
Create a header for a Msg
.
IJulia.send_ipython
— Functionsend_ipython(socket, m::Msg)
Send a message m
. This will lock socket
.
IJulia.recv_ipython
— Functionrecv_ipython(socket)
Wait for and get a message. This will lock socket
.
IJulia.set_cur_msg
— FunctionJupyter 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.
IJulia.send_status
— Functionsend_status(state::AbstractString, parent_msg::Msg=execute_msg)
Publish a status message.
Request handlers
IJulia.connect_request
— Functionconnect_request(socket, msg)
Handle a connect request.
IJulia.execute_request
— Functionexecute_request(socket, msg)
Handle a execute request. This will execute Julia code, along with Pkg and shell commands.
IJulia.shutdown_request
— Functionshutdown_request(socket, msg)
Handle a shutdown request. After sending the reply this will exit the process.
IJulia.interrupt_request
— Functioninterrupt_request(socket, msg)
Handle a interrupt request. This will throw an InterruptException
to the currently executing request handler.
IJulia.inspect_request
— Functioninspect_request(socket, msg)
Handle a introspection request.
IJulia.history_request
— Functionhistory_request(socket, msg)
Handle a history request. This is currently only a dummy implementation that doesn't actually do anything.
IJulia.complete_request
— Functioncomplete_request(socket, msg)
Handle a completion request.
IJulia.kernel_info_request
— Functionkernel_info_request(socket, msg)
Handle a kernel info request.
IJulia.is_complete_request
— Functionis_complete_request(socket, msg)
Handle a completeness request.
Event loop
IJulia.eventloop
— Functioneventloop(socket)
Generic event loop for one of the kernel sockets.
IJulia.waitloop
— Functionwaitloop()
Main loop of a kernel. Runs the event loops for the control and shell sockets (note: in IJulia the shell socket is called requests
).
IO
IJulia.IJuliaStdio
— TypeWrapper type around redirected stdio streams, both for overloading things like flush
and so that we can set properties like color
.
IJulia.capture_stdout
— ConstantThe 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
.
IJulia.capture_stderr
— ConstantThe 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
.
IJulia.watch_stream
— Functionwatch_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.
Multimedia display
IJulia.InlineDisplay
— TypeStruct to dispatch on for inline display.
IJulia.InlineIOContext
— FunctionInlineIOContext(io, KVs::Pair...)
Create an IOContext
for inline display.
IJulia.ipy_mime
— ConstantSupported MIME types for inline display in IPython, in descending order of preference (descending "richness").
IJulia.ijulia_mime_types
— ConstantA 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.
IJulia.ijulia_jsonmime_types
— ConstantMIME 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).
IJulia.limitstringmime
— Functionlimitstringmime(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.
IJulia.israwtext
— FunctionNeed 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.
IJulia.display_dict
— FunctionGenerate 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.
IJulia.display_mimejson
— FunctionGenerate 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
).
IJulia.display_mimestring
— FunctionGenerate the preferred MIME representation of x.
Returns a tuple with the selected MIME type and the representation of the data using that MIME type.
IJulia.register_mime
— Functionregister_mime(x::Union{MIME, Vector{MIME}})
register_mime(x::AbstractVector{<:MIME})
Register a new MIME type.
IJulia.register_jsonmime
— Functionregister_jsonmime(x::Union{MIME, Vector{MIME}})
register_jsonmime(x::AbstractVector{<:MIME})
Register a new JSON MIME type.
Jupyter
IJulia.find_jupyter_subcommand
— Functionfind_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.
IJulia.launch
— Functionlaunch(cmd, dir, detached)
Run cmd
in dir
. If detached
is false
it will not wait for the command to finish.
Debugging
IJulia.set_verbose
— Functionset_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.
Utility
IJulia.num_utf8_trailing
— FunctionIf d
ends with an incomplete UTF8-encoded character, return the number of trailing incomplete bytes. Otherwise, return 0
.