Created
February 14, 2014 02:01
-
-
Save zonca/8994544 to your computer and use it in GitHub Desktop.
Submit non-python commands to a running IPython cluster
This file contains 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 sys | |
from IPython.parallel import Client | |
def run_command(command): | |
import subprocess | |
subprocess.Popen(command, shell = True) | |
try: | |
filename = sys.argv[1] | |
except: | |
print """Usage: ipcluster_run_commands.py filename | |
filename is a list of commands, one per line, | |
to be submitted to an already running IPython cluster""" | |
sys.exit(1) | |
list_of_commands = open(filename, 'r').readlines() | |
rc = Client() | |
lview = rc.load_balanced_view() | |
lview.map(run_command, list_of_commands) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment