Skip to content

Commit a7c9235

Browse files
authored
[REPL] prevent silent hang if precompile script async blocks fail (#55685)
1 parent bcf41ba commit a7c9235

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

stdlib/REPL/src/Terminals.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ abstract type UnixTerminal <: TextTerminal end
9797
pipe_reader(t::UnixTerminal) = t.in_stream::IO
9898
pipe_writer(t::UnixTerminal) = t.out_stream::IO
9999

100+
@nospecialize
100101
mutable struct TerminalBuffer <: UnixTerminal
101102
out_stream::IO
102103
end
@@ -107,6 +108,7 @@ mutable struct TTYTerminal <: UnixTerminal
107108
out_stream::IO
108109
err_stream::IO
109110
end
111+
@specialize
110112

111113
const CSI = "\x1b["
112114

stdlib/REPL/src/precompile.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ let
9696
repltask = @task try
9797
Base.run_std_repl(REPL, false, :yes, true)
9898
finally
99-
redirect_stderr(isopen(orig_stderr) ? orig_stderr : devnull)
99+
redirect_stdin(isopen(orig_stdin) ? orig_stdin : devnull)
100100
redirect_stdout(isopen(orig_stdout) ? orig_stdout : devnull)
101101
close(pts)
102102
end
@@ -106,14 +106,14 @@ let
106106
redirect_stdin(pts)
107107
redirect_stdout(pts)
108108
redirect_stderr(pts)
109-
REPL.print_qualified_access_warning(Base.Iterators, Base, :minimum) # trigger the warning while stderr is suppressed
110109
try
111-
schedule(repltask)
112-
# wait for the definitive prompt before start writing to the TTY
113-
readuntil(output_copy, JULIA_PROMPT)
110+
REPL.print_qualified_access_warning(Base.Iterators, Base, :minimum) # trigger the warning while stderr is suppressed
114111
finally
115112
redirect_stderr(isopen(orig_stderr) ? orig_stderr : devnull)
116113
end
114+
schedule(repltask)
115+
# wait for the definitive prompt before start writing to the TTY
116+
readuntil(output_copy, JULIA_PROMPT)
117117
write(debug_output, "\n#### REPL STARTED ####\n")
118118
sleep(0.1)
119119
readavailable(output_copy)
@@ -148,9 +148,9 @@ let
148148
write(ptm, "$CTRL_D")
149149
wait(repltask)
150150
finally
151-
close(pts)
152151
redirect_stdin(isopen(orig_stdin) ? orig_stdin : devnull)
153152
redirect_stdout(isopen(orig_stdout) ? orig_stdout : devnull)
153+
close(pts)
154154
end
155155
wait(tee)
156156
end

0 commit comments

Comments
 (0)