IPython Parallel - Simple Test

Show the number of process available across all nodes


In [ ]:
from ipyparallel import Client

# IPython Parallel profile
profile_dir = "/home/data/ipython/profile"
rc = Client(profile_dir=profile_dir)

print "Available Processes: {0}".format(len(rc.ids))

Show the Process ID (PID) of each process across all nodes


In [ ]:
dview = rc.direct_view()
with dview.sync_imports():
    import os
    
    dview.block=True
    pids = dview.apply(os.getpid)
    dview.block=False
    ar = dview.apply(os.getpid)
    dview.wait(ar)
    pids = ar.get()
    print ''
    print 'PID of each process',pids

In [ ]: