Created
January 7, 2016 19:11
-
-
Save Kwpolska/f9cda61951dc7dad4c79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import time | |
| p = subprocess.Popen(['error-prone', 'thing'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| while p.poll() is None: | |
| time.sleep(0.5) # prevent 100% CPU usage | |
| if p.returncode != 0: | |
| stdout, stderr = p.communicate() | |
| print("The process failed with code {0}.\nstdout:\n{1}\nstderr:\n{2}".format(p.returncode, stdout, stderr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment