From 9fcf82d18cfcea3f3ce7dc42944013dd2dc673e4 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 10 Mar 2023 09:43:39 +0100 Subject: [PATCH] kill precompilation process if it is too slow (#301) some users have reported OhMyREPL getting stuck precompiling, this should fix this in a non-idea way --- src/OhMyREPL.jl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/OhMyREPL.jl b/src/OhMyREPL.jl index 333c6ce..825486e 100644 --- a/src/OhMyREPL.jl +++ b/src/OhMyREPL.jl @@ -157,12 +157,22 @@ OhMyREPL.TerminalRegressionTests.create_automated_test( end """ -p = run(pipeline(ignorestatus(`$(Base.julia_cmd()) --project=$(Base.active_project()) --trace-compile=$tracecompile_file --compiled-modules=no -e $content`); stderr=devnull)) -if p.exitcode != 0 - # There seems to be some finalizer problem from VT100... - # @warn "OhMyREPL internal precompilation failed" +function run_with_timeout(command, timeout::Integer = 25) + cmd = run(command; wait=false) + for _ in 1:timeout + if !process_running(cmd) return success(cmd) end + sleep(1) + end + @warn "OhMyREPL precompilation not finished in time, killing" + kill(cmd) + return false end + +run_with_timeout( + pipeline(ignorestatus(`$(Base.julia_cmd()) --project=$(Base.active_project()) --trace-compile=$tracecompile_file --compiled-modules=no -e $content`); stderr=devnull) +) + num_prec = 0 for line in eachline(tracecompile_file) try