Possible Duplicate:
Non-blocking read on a subprocess.PIPE in python
Is it possible to test whether a Python file-like object has charaters after the current read position?
I’m trying to keep a subprocess.PIPE flushed to my stdout, so am continuously running read(1) on it. I only want to read if there will actually be something there for me to get (otherwise it hangs until something shows up).
A
subprocess.PIPEis not just a file-like, it is an actual file. As such you can get its file descriptor and pass it toselect.select()or similar functions.