(original) (raw)


On 28/03/2014 06:35 pm, Josiah Carlson wrote:

If it were me, I'd define three methods, with longer names to clarify what they do, e.g.

proc.write\_nonblocking(data)
data = proc.read\_nonblocking()
data = proc.read\_stderr\_nonblocking()

Easily doable.
To implement write\_nonblocking() on Windows, do you intend to use SetNamedPipeHandleState() with PIPE\_NOWAIT? The documentation discourages using this:

Note that nonblocking mode is supported for compatibility with
Microsoft LAN Manager version 2.0 and should not be used to
achieve asynchronous input and output (I/O) with named pipes.


And I guess you will need to use a poll/sleep loop to simulate blocking or multiplexing. If you want expect-like behaviour then you need some sort of multiplexing.

\-- RIchard