-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
print/println should block write final output #3787
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
Comments
"block" as in "write as a single block" |
This behavior doesn't seem so great. It's easy to write a string and a newline in a single operation, but we don't want to have to worry about that sort of thing all the time. Maybe some sort of buffering is the answer? @loladiro |
libuv has the capability to write multiple things at once. It's just that our I/O system doesn't work that way. Making TTY's nonblocking seems fine, since writing to TTYs blocks the whole process anyway. |
But, we have to arrange for the output to be consistent over the different kinds of streams. It would be bad to get different output when redirecting to a file than when testing by printing to the screen. |
I don't think you can insist on that. In fact in most situations, you can probably not even depend on the output being the same between julia runs. |
Line buffering for text streams seems reasonable to me. But of course, we then need a distinction between printing to a text stream and printing to a byte stream, but we've talked about that before already. |
Maybe we can''t insist on identical output in all sorts of scenarios, but getting the expected output at the prompt and then one of Amit's outputs above in a file seems gratuitous to me. The sensitivity to |
I suspect this is showing up now because we are now doing blocking writes, which presumably means there is a a task switch required by each call to the low-level write function. Another possibility is to introduce locking:
Where lock/unlock are the traditional recursive binary semaphores. I'm not sure exactly where this would be put into the hierarchy of show/print. |
No way; I don't want to have to use that lock stuff just to break some output into two print calls. |
Regression in 334a2be |
Is the third post in #12600 a related issue? |
@Sisyphuss , #12600 is not related and not a bug. |
@amitmurthy no I meant the output format: the output "0" is between the print "x:1" and "x:2, x:3". |
I also get a lot of interleaved printing between Julia and Jupyer in my notebooks. |
@KristofferC can you post examples? Currently only |
As folks start working with more parallel constructs, it will be good to have print/println do a block write of the final string.
The newline is written separately.
The text was updated successfully, but these errors were encountered: