Skip to content

Commit c50fd4a

Browse files
authored
Call _showerror in a pyregion (#845)
Otherwise just displaying an error message can take multiple seconds with other threads running.
1 parent fcb6a7c commit c50fd4a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/Core/err.jl‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ file_to_pymodule(fname::String) = begin
9191
end
9292
end
9393

94-
Base.showerror(io::IO, e::PyException) = _showerror(io, e, nothing, backtrace = false)
94+
# We take a single region here so that formatting doesn't re-acquire the GIL for
95+
# every operation, which otherwise can be very slow with multiple threads trying
96+
# to take the GIL.
97+
Base.showerror(io::IO, e::PyException) =
98+
@pyregion _showerror(io, e, nothing, backtrace = false)
9599

96100
Base.showerror(io::IO, e::PyException, bt; backtrace = true) =
97-
_showerror(io, e, bt; backtrace = backtrace)
101+
@pyregion _showerror(io, e, bt; backtrace = backtrace)
98102

99103
function _showerror(io::IO, e::PyException, bt; backtrace = true)
100104
print(io, "Python: ")

0 commit comments

Comments
 (0)