Skip to content
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

prints from PythonCall or PyCall are buffered #1656

Closed
klaff opened this issue Nov 10, 2021 · 2 comments
Closed

prints from PythonCall or PyCall are buffered #1656

klaff opened this issue Nov 10, 2021 · 2 comments
Labels
other packages Integration with other Julia packages

Comments

@klaff
Copy link

klaff commented Nov 10, 2021

If I make a notebook with two cells:
using PythonCall
and
pyprint("Hello world!")

or equivalently:
using PyCall
and
py"print('hello world!')"

the printed text does not appear in the terminal running the Pluto server until the notebook is closed or after a much larger amount of text (~ 10 kB?) has been printed. with_terminal() from PlutoUI doesn't work with this either.

@fonsp
Copy link
Owner

fonsp commented Nov 15, 2021

Thanks for the report! It looks like this is a bug in the combination of PyCall and Distributed:

julia> using Distributed

julia> p = Distributed.addprocs(1) |> first
2

julia> Distributed.remotecall_eval(Main, p, :(using PyCall))

julia> Distributed.remotecall_eval(Main, p, :(py"print('hello world!')"))

julia> # nothing is printed

julia> Distributed.rmprocs(p)
      From worker 2:	hello world!
Task (done) @0x000000011d5bf860

julia> 

Pluto uses the Distributed stdlib to manage notebook processes, which means that we probably won't be able to fix this on our side. Try reporting the example above to PyCall.jl or to julia.

@fonsp fonsp closed this as completed Nov 15, 2021
@fonsp fonsp added the other packages Integration with other Julia packages label Nov 15, 2021
@rashidrafeek
Copy link

As mentioned in the other issue: JuliaPy/PythonCall.jl#68 (comment), the following is a workaround:

pyprint("hello world", flush=true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

3 participants