Created
March 23, 2018 08:19
-
-
Save albertyw/fb79f633a6f6991b620334ded1ce7dd2 to your computer and use it in GitHub Desktop.
subprocess example
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 | |
| commands = ['./time.sh'] * 5 | |
| outputs = [None] * len(commands) | |
| processes = [None] * len(commands) | |
| start = time.time() | |
| for i, command in enumerate(commands): | |
| process = subprocess.Popen([command], stdout=subprocess.PIPE) | |
| processes[i] = process | |
| for i, process in enumerate(processes): | |
| outputs[i] = process.communicate() | |
| print(i, outputs[i]) | |
| print('elapsed seconds: ', time.time() - start) |
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
| #!/bin/bash | |
| sleep 2 | |
| date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment