osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subprocess Popen confusion



> On 18 May 2020, at 21:50, Dick Holmes <encore1 at cox.net> wrote:

snip

> Per Peter's suggestion I tried readline and it works "as expected". I 
> also discovered that the reason the read operations were stalling was 
> that they followed a write and the write doesn't actually occur until 
> "flush" is called even though the function call returns. There are 
> undoubtedly some subtleties lurking about, but at least I'm making good 
> progress.

You need the flush() because the stream is using buffered I/O.

Each write adds to the buffer inside python and when then buffer if full it is
written out of Python into the OS.

As you found you can force a partial buffer to be written by calling flush().

Barry


> 
> Thanks for the help!
> 
> Dick
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list <https://mail.python.org/mailman/listinfo/python-list>