Created
December 19, 2016 03:25
-
-
Save bcatubig/5a9b430bb49ccc45d611bc347bd13226 to your computer and use it in GitHub Desktop.
Python Bash Multiprocessing
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 | |
ps = [] | |
def main(): | |
for i in range(1,5): | |
p = subprocess.Popen("ansible all -i localhost, -c local -a 'date'", shell=True) | |
ps.append(p) | |
while True: | |
ps_status = [p.poll() for p in ps] | |
if all([x is not None for x in ps_status]): | |
break | |
print("[+] Done Processing") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
POC for running multiple bash commands in parallel
similiar to
Output