Skip to content

Instantly share code, notes, and snippets.

@jseabold
Created March 29, 2013 20:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jseabold/5273347 to your computer and use it in GitHub Desktop.
Save jseabold/5273347 to your computer and use it in GitHub Desktop.
Start an IPython cluster with subprocess
"""
Creates a task interface.
Change to
view = rc[:]
for a direct interface.
"""
from IPython.parallel import Client
def launch_cluster(n=4, *args):
from subprocess import Popen, PIPE
return Popen(['ipcluster', 'start', '-n', str(n)] + list(args), stdout=PIPE, stderr=PIPE)
try:
rc = Client()
view = rc.load_balanced_view()
except IOError:
launch_cluster()
import time
time.sleep(5)
rc = Client()
view = rc.load_balanced_view()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment