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

Writing more than 64 kb to stdout #243

Open
philip4096 opened this issue Oct 23, 2014 · 7 comments
Open

Writing more than 64 kb to stdout #243

philip4096 opened this issue Oct 23, 2014 · 7 comments

Comments

@philip4096
Copy link

I am calling something that writes more than 64 kb to stdout from IJulia Notebook and the process stalls. Less than 64 kb works and doing the same thing on a worker process (or outside Ijulia notebook) works fine.

@stevengj
Copy link
Member

I can't reproduce:

randstring(n) = ASCIIString([uint8(rand('#':'z')) for i = 1:n])
print(randstring(2^17))

works fine for me (128kiB output). Does this example fail for you? What is the output of versioninfo()?

@philip4096
Copy link
Author

Your example works fine. versioninfo() below. I am using PyCall and the win32com.client python module to call COM-functions. Since exactly the same thing works in a standalone julia process I didn't think it was a python issue.

Julia Version 0.3.1
Commit c03f413 (2014-09-21 21:30 UTC)
Platform Info:
System: Windows (i686-w64-mingw32)
CPU: Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz
WORD_SIZE: 32
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3

@stevengj
Copy link
Member

What about:

ccall(:puts, Cint, (Ptr{Uint8},), randstring(2^17))

? That works for me, but maybe there is a problem with the libc I/O interactions on your machine?

As shown from my example code, there is no inherent problem in IJulia and IPython with more than 64kB standard output, so I'm not sure where the problem lies on your machine.

@stevengj
Copy link
Member

Actually, now I see a problem on my machine:

ccall(:puts, Cint, (Ptr{Uint8},), string([1:2^16]))

returns -1 (EOF) and the output is clearly truncated, so something is going wrong with libc I/O for me too (MacOS 10.9). (Whereas it works in the terminal, so it has something to do with the I/O redirection in IJulia.)

cc: @vtjnash

@stevengj
Copy link
Member

I'm closing this in favor of JuliaLang/julia#8789, since I was able to reproduce the problem outside IJulia by redirecting stdout.

@philip4096
Copy link
Author

OK, good, thank you!

@stevengj
Copy link
Member

stevengj commented Jun 4, 2015

Re-opening this issue as it is not a Julia problem per se, it is an OS limitation for reading and writing a buffer device from the same thread.

The only solution would be to somehow instantiate a genuine OS thread that is responsible for reading the IO buffers; this is theoretically possible but will require some work (possibly at the C level).

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

No branches or pull requests

2 participants