Open schlichtanders opened 8 months ago
Here a MWE run julia docker with
docker run -it --rm julia:1.9 bash
and start julia
. Then run the following code and while the last sleep
is running, hit CTRL-c to interrupt the julia session
import Pkg
Pkg.add(["HTTP", "PythonCall", "Sockets"])
using HTTP
using PythonCall
import Sockets
function default_404(req = nothing)
HTTP.Response(404, "Not found!")
end
router = HTTP.Router(default_404)
@warn "pid = ..."
os = pyimport("os")
pid = os.getpid()
@warn "pid = $pid"
function get_pid(request::HTTP.Request)
@warn "pid = ..."
os = pyimport("os")
pid = os.getpid()
@warn "pid = $pid"
return HTTP.Response(200, string(pid))
end
HTTP.register!(router, "GET", "/pid", get_pid)
port = UInt16(32132)
serversocket = Sockets.listen(port)
server = HTTP.listen!(port; stream=true, server=serversocket, verbose=-1) do http::HTTP.Stream
request::HTTP.Request = http.message
request.body = read(http)
response_body = router(request)
@show response_body
request.response::HTTP.Response = response_body
request.response.request = request
try
HTTP.setheader(http, "Content-Length" => string(length(request.response.body)))
# https://github.com/fonsp/Pluto.jl/pull/722
HTTP.setheader(http, "Referrer-Policy" => "same-origin")
# https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#:~:text=is%202%20minutes.-,14.38%20Server
HTTP.startwrite(http)
write(http, request.response.body)
catch e
if isa(e, Base.IOError) || isa(e, ArgumentError)
# @warn "Attempted to write to a closed stream at $(request.target)"
@debug "that is fine error" exception=(e, catch_backtrace())
else
rethrow(e)
end
end
end
sleep(2)
HTTP.get("http://localhost:$port/pid")
sleep(100)
It gives the following error
julia> sleep(10)
^C^C^CSYSTEM ERROR: Failed to report error to REPL frontend^Cfatal: error thrown and no exception handler available.
InterruptException()
_jl_mutex_unlock at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/threading.c:805
jl_mutex_unlock at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia_locks.h:81 [inlined]
jl_lookup_generic_ at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2912 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2936
scrub_repl_backtrace at ./client.jl:102
_start at ./client.jl:524
jfptr__start_40034.clone_1 at /usr/local/julia/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
true_main at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7fc40aa221c9)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
root@b66abeaaf63d:/#
exit
Affects: PythonCall
Describe the bug I just turned off threads to make PythonCall work, but now I experience that every time I try interrupting the julia REPL (with PythonCall loaded and used inside a WebServer) it results in a fatal error which crashes the whole Julia REPL (however I would like to stay in the julia REPL)
Here the error message
I was not able to simplify it to a MWE yet. Maybe the above error is already somehow self-explaining.
Your system Please provide detailed information about your system: