Mar-07-2022, 08:46 PM
(This post was last modified: Mar-07-2022, 08:49 PM by Gribouillis.)
Skaperen Wrote:i am tying to avoid system specific code as much as i can.
I think the "pipe" terminology is confusing. If you start a child process with
child = subprocess.Popen(...)
and you wait for incoming data from child.stdout
, this file object should work in the selectors module, so you could write OS agnostically (untested)sel = selectors.DefaultSelector() sel.register(child.stdout, selectors.EVENT_READ) pairs = sel.select(timeout=1) if pairs: data = child.stdout.readline() # or perhaps read(1024) ? ... else: # timed out # terminate child process ?