Skip to content

Commit

Permalink
[REPL] prevent silent hang if precompile script async blocks fail (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Sep 10, 2024
1 parent bcf41ba commit a7c9235
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions stdlib/REPL/src/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ abstract type UnixTerminal <: TextTerminal end
pipe_reader(t::UnixTerminal) = t.in_stream::IO
pipe_writer(t::UnixTerminal) = t.out_stream::IO

@nospecialize
mutable struct TerminalBuffer <: UnixTerminal
out_stream::IO
end
Expand All @@ -107,6 +108,7 @@ mutable struct TTYTerminal <: UnixTerminal
out_stream::IO
err_stream::IO
end
@specialize

const CSI = "\x1b["

Expand Down
12 changes: 6 additions & 6 deletions stdlib/REPL/src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ let
repltask = @task try
Base.run_std_repl(REPL, false, :yes, true)
finally
redirect_stderr(isopen(orig_stderr) ? orig_stderr : devnull)
redirect_stdin(isopen(orig_stdin) ? orig_stdin : devnull)
redirect_stdout(isopen(orig_stdout) ? orig_stdout : devnull)
close(pts)
end
Expand All @@ -106,14 +106,14 @@ let
redirect_stdin(pts)
redirect_stdout(pts)
redirect_stderr(pts)
REPL.print_qualified_access_warning(Base.Iterators, Base, :minimum) # trigger the warning while stderr is suppressed
try
schedule(repltask)
# wait for the definitive prompt before start writing to the TTY
readuntil(output_copy, JULIA_PROMPT)
REPL.print_qualified_access_warning(Base.Iterators, Base, :minimum) # trigger the warning while stderr is suppressed
finally
redirect_stderr(isopen(orig_stderr) ? orig_stderr : devnull)
end
schedule(repltask)
# wait for the definitive prompt before start writing to the TTY
readuntil(output_copy, JULIA_PROMPT)
write(debug_output, "\n#### REPL STARTED ####\n")
sleep(0.1)
readavailable(output_copy)
Expand Down Expand Up @@ -148,9 +148,9 @@ let
write(ptm, "$CTRL_D")
wait(repltask)
finally
close(pts)
redirect_stdin(isopen(orig_stdin) ? orig_stdin : devnull)
redirect_stdout(isopen(orig_stdout) ? orig_stdout : devnull)
close(pts)
end
wait(tee)
end
Expand Down

0 comments on commit a7c9235

Please sign in to comment.