diff --git a/deps/kspec.jl b/deps/kspec.jl index 6b3bd37b..dd8bbc32 100644 --- a/deps/kspec.jl +++ b/deps/kspec.jl @@ -83,6 +83,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...; "display_name" => name * " " * Base.VERSION_STRING * debugdesc, "language" => "julia", "env" => env, + "interrupt_mode" => "message", ) mkpath(juliakspec) diff --git a/src/eventloop.jl b/src/eventloop.jl index 9293ac3b..dd818501 100644 --- a/src/eventloop.jl +++ b/src/eventloop.jl @@ -32,16 +32,17 @@ function eventloop(socket) end end +requests_task = Ref{Task}() function waitloop() @async eventloop(control[]) - requests_task = @async eventloop(requests[]) + requests_task[] = @async eventloop(requests[]) while true try wait() catch e # send interrupts (user SIGINT) to the code-execution task if isa(e, InterruptException) - @async Base.throwto(requests_task, e) + @async Base.throwto(requests_task[], e) else rethrow() end diff --git a/src/handlers.jl b/src/handlers.jl index 1fb461cb..4d1bba22 100644 --- a/src/handlers.jl +++ b/src/handlers.jl @@ -261,6 +261,11 @@ function is_complete_request(socket, msg) Dict("status"=>status, "indent"=>""))) end +function interrupt_request(socket, msg) + @async Base.throwto(requests_task[], InterruptException()) + send_ipython(requests[], msg_reply(msg, "interrupt_reply", Dict())) +end + const handlers = Dict{String,Function}( "execute_request" => execute_request, "complete_request" => complete_request, @@ -270,6 +275,7 @@ const handlers = Dict{String,Function}( "shutdown_request" => shutdown_request, "history_request" => history_request, "is_complete_request" => is_complete_request, + "interrupt_request" => interrupt_request, "comm_open" => comm_open, "comm_info_request" => comm_info_request, "comm_msg" => comm_msg, diff --git a/src/msg.jl b/src/msg.jl index 6208d2ee..74012b81 100644 --- a/src/msg.jl +++ b/src/msg.jl @@ -20,7 +20,7 @@ msg_header(m::Msg, msg_type::String) = Dict("msg_id" => uuid4(), "session" => m.header["session"], "date" => now(), "msg_type" => msg_type, - "version" => "5.0") + "version" => "5.3") # PUB/broadcast messages use the msg_type as the ident, except for # stream messages which use the stream name (e.g. "stdout").