Skip to content

Instantly share code, notes, and snippets.

@zonca
Created February 14, 2014 02:01
Show Gist options
  • Save zonca/8994544 to your computer and use it in GitHub Desktop.
Save zonca/8994544 to your computer and use it in GitHub Desktop.
Submit non-python commands to a running IPython cluster
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