![]() |
flushing output buffers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: flushing output buffers (/thread-40472.html) |
flushing output buffers - Skaperen - Aug-03-2023 output to 2 open files that are buffered may get alternating output calls. when that output finally goes to a common file destination, output is mixed, but not necessarily in the same order as the original output calls like print(). i want to get the correct output mix order. does Python have a way to do that (such as a flush_all() call that knows how to do it from stored info)? or is it better to modify the files to be unbuffered? what action would you do? in C, i did not solve this problem other that by modifying the calling code to flush the buffer after each PUT. RE: flushing output buffers - Gribouillis - Aug-03-2023 Can you post a piece of code having the bad behavior? I'm curious to see it at work. RE: flushing output buffers - Skaperen - Aug-04-2023 (Aug-03-2023, 04:31 AM)Gribouillis Wrote: Can you post a piece of code having the bad behavior? I'm curious to see it at work.i'd like to, but i don't know how to reproduce the buffering effects that sometimes happen. RE: flushing output buffers - PyDan - Aug-04-2023 Not sure if this helps, but I had to implement a flush, when redirecting in my embedded python. In C++, it was enough to use std::endl… maybe just end your print with a “\n” RE: flushing output buffers - Skaperen - Aug-06-2023 maybe that is the cause of some or all effects. maybe it holds back a flush unless a line ends with something equivalent to a line end ( in "\n\v\f\r" ) or when a buffer level is reached or before it would be exceeded. i'll think about ways to test that.
|