Created
March 29, 2013 20:17
-
-
Save jseabold/5273347 to your computer and use it in GitHub Desktop.
Start an IPython cluster with subprocess
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
""" | |
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