+ # Change tarp's stdout and stderr to non-blocking
+ for s in [tarp.stdout, tarp.stderr]:
+ fd = s.fileno()
+ fl = fcntl.fcntl(fd, fcntl.F_GETFL)
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
+
+ def readlineNonBlocking(stream):
+ """Read a line nonblocking. Returns b'' if nothing read."""
+ try:
+ return stream.readline()
+ except:
+ return b''
+ pass
+
+
+ # Read stdout and stderr of tarp
+ errmsg = b""