Since the subprocess call is blocked, one way to print something while waiting is to use multithreading. Here is an example using threading._Timer:
import threading import subprocess class RepeatingTimer(threading._Timer): def run(self): while True: self.finished.wait(self.interval) if self.finished.is_set(): return else: self.function(*self.args, **self.kwargs) def status(): print "I'm alive" timer = RepeatingTimer(1.0, status) timer.daemon = True
In an unrelated note, calling stdout.read () when using multiple pipes can lead to a deadlock. Instead, use the subprocess.communicate () function.
source share