import subprocess from time import sleep # job is a Popen object, see the docs for other options that allow you # to get stderr and stdout: # https://docs.python.org/3.6/library/subprocess.html job = subprocess.Popen(['/bin/sleep', '5']) # the poll method checks the return code, and is 'None' if the program is # still running while job.poll() is None: print("still waiting to finish...") sleep(0.5) else: print("All done, return status:", job.poll())