-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using Pluto, output from pyprint is buffered #68
Comments
Similar behavior occurs with PyCall - this may be a Pluto issue. |
Closing on the assumption it is a Pluto bug: fonsp/Pluto.jl#1656 |
@klaff Please reopen The problem is still existing and the linked Pluto issues explicitly states that this is not a Pluto bug, but a bad interaction of PythonCall and Distributed printing. |
I adapted the example to show what is missing: julia> using Distributed
julia> p = Distributed.addprocs(1) |> first
2
julia> Distributed.remotecall_eval(Main, p, :(using PythonCall))
julia> Distributed.remotecall_eval(Main, p, :(print("hello Julia!")))
julia> Distributed.remotecall_eval(Main, p, :(@info("flush")))
From worker 2: hello Julia![ Info: flush
julia> Distributed.remotecall_eval(Main, p, :(pyprint("hello PythonCall!")))
julia> Distributed.remotecall_eval(Main, p, :(@info("flush")))
From worker 2: [ Info: flush
julia> Distributed.rmprocs(p)
From worker 2: hello PythonCall!
Task (done) @0x00007f96a3589aa0 The "hello PythonCall!" output should be printed together with "flush". |
Found a workaround: Explicitly call flush from python side pyprint("hello world", flush=true) |
Yes indeed, the issue is that in Python stdout has a large buffer by default (unless it's an interactive session and it line buffers too) which isn't being flushed as often as you'd like. You just need to flush it yourself. I suppose that if PythonCall could detect that it's running inside a Distributed worker and that the main process is interactive, then it could force Python's stdout to line buffer. Sounds tricky though. |
From within Pluto,
pyprint("hello world!")
does not immediately print to the terminal running the Pluto server. Also, if one usesPlutoUI
andwith_terminal() do ...
, the output also does not immediately print.If the notebook is stopped, or if one
pyprint
s a large number of bytes (~ 10 kB?) then the buffered output of thepyprint
statements will be displayed.To replicate, start a Pluto notebook by
using Pluto; Pluto.run()
, then create a new notebook with one cell containingusing PythonCall
and one containingpyprint("hello world!")
.The text was updated successfully, but these errors were encountered: