Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
import sys print('stderr1', file=sys.stderr) print('stdout1') print('stderr2', file=sys.stderr) print('stdout2')
This happens with:
The error does not occur with:
... where the order is as expected.
I've already reported this quite some time ago in jupyter/help#111, where there was some chit-chat and then I was sent here.
It might have been pointed out before, but that's (AFAIU) how stderr/out are supposed to work, even C is affected:
It's also consistent with what I get in my shell when I call a pure python script: (called many time to show the randomness or order).
So I would like to be careful to not guaranty a behavior that happen to appear to work in IPython in some shells but not in Python.
@Carreau Thanks for trying this out!
How did you call this script?
I understand that
And that's why the current
So I'll have to update the expected case I mentioned above. In addition to one expected output (in the order of calls)
... I wouldn't be surprised if sometimes some
But I would never expect
So why does
I don't know how exactly the buffering works in
Regarding the "flushing" solution suggested by @takluyver: What about making it asymmetrical and only flush
All of these solutions would probably to some extent emulate the behavior of