Skip to content

Commit 2728e20

Browse files
authored
flush Python I/O in IJulia (#982)
1 parent 6b18f38 commit 2728e20

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pyinit.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ function __init__()
256256
end
257257
end
258258

259+
# ensure Jupyter/IJulia flushes I/O streams (issue #912)
260+
if isdefined(Main, :IJulia) && IJulia.inited
261+
Main.IJulia.push_postexecute_hook() do
262+
sys = pyimport("sys")
263+
sys."stdout"."flush"()
264+
sys."stderr"."flush"()
265+
end
266+
end
267+
259268
# Configure finalization steps.
260269
#
261270
# * In julia/PyCall, `julia` needs to call `Py_Finalize` to

0 commit comments

Comments
 (0)