Skip to content

Instantly share code, notes, and snippets.

@albertyw
Created March 23, 2018 08:19
Show Gist options
  • Save albertyw/fb79f633a6f6991b620334ded1ce7dd2 to your computer and use it in GitHub Desktop.
Save albertyw/fb79f633a6f6991b620334ded1ce7dd2 to your computer and use it in GitHub Desktop.
subprocess example
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)
#!/bin/bash
sleep 2
date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment