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

truncation of very long outputs #1

Closed
anntzer opened this issue Sep 1, 2016 · 10 comments · Fixed by #8
Closed

truncation of very long outputs #1

anntzer opened this issue Sep 1, 2016 · 10 comments · Fixed by #8

Comments

@anntzer
Copy link

anntzer commented Sep 1, 2016

Found while working on Calysto/matlab_kernel#5: wurlitzer truncates very long outputs. A minimal example is

Python 3.5.2 (default, Jun 28 2016, 08:46:01) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %load_ext wurlitzer

In [2]: import ctypes; ctypes.CDLL(None).printf(b"%s", "\n".join(map(str, range(10000))).encode("
   ...: ascii"))

and the list of printed numbers stops around 280.

(It is even more annoying from the point of view of the MATLAB kernel as it simply hangs during the call to libc.fflush(c_stdout_p); I suspect the issues are related.)

@anntzer
Copy link
Author

anntzer commented Sep 7, 2016

FWIW I worked around this by commenting out the calls fflush in the forwarder loop. I'm not sure they're necessary?

@minrk
Copy link
Owner

minrk commented Sep 7, 2016

Thanks for the test!

They do seem to be necessary to ensure that you get all of the outputs at the right time. I'll see if there's a better way to accomplish that.

@minrk
Copy link
Owner

minrk commented Sep 7, 2016

What OS are you on, BTW? I'm getting correct behavior when I run the example in a kernel on OS X. I do see the truncation when I run it in terminal IPython, though.

@minrk
Copy link
Owner

minrk commented Sep 7, 2016

I just realized that it doesn't make any sense to use wurlitzer in terminal IPython, and I should make it raise if you try. Are you seeing this same truncation with this example in notebook/qtconsole?

@minrk
Copy link
Owner

minrk commented Sep 7, 2016

I opened #2 which fixes the truncation in terminal IPython by disabling wurlitzer entirely in terminal IPython (there's nothing to capture when you are already in a terminal). I haven't been able to reproduce the truncation with a kernel, though.

@anntzer
Copy link
Author

anntzer commented Sep 7, 2016

Hum, then the issue I was hitting with the MATLAB kernel was a separate one. Blockage also occurs with the qtconsole (with ipython/ipython#1392 appearing too). It does not seem to occur with the notebook though.

Edit: I am on Arch Linux.

@minrk
Copy link
Owner

minrk commented Sep 8, 2016

There is nothing different about the kernel when running in the qtconsole vs the notebook, so I'm not sure how the kernel behavior could be different unless it happens to be running in a different environment (check sys.executable, sys.path). Perhaps it's just a coincidence and it only happens sometimes in both cases?

@anntzer
Copy link
Author

anntzer commented Sep 8, 2016

Actually, I'm going to take back what I said: I also observe blockage with the notebook, just that the threshold seems different (higher). When blockage occurs, it occurs 100% of the times.

@minrk
Copy link
Owner

minrk commented Sep 9, 2016

With the same ctypes command, or do you have another one that's more reliable for causing the block?

@anntzer
Copy link
Author

anntzer commented Sep 9, 2016

With the MATLAB kernel (https://github.com/Calysto/matlab_kernel). Yes, I know, it's not easily reproducible if you don't have MATLAB available :-(

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

Successfully merging a pull request may close this issue.

2 participants