from IPython import parallel rc = parallel.Client() def print_stuff(n): """dummy task that prints stuff""" import os, sys for i in range(n): print i, os.getpid() # stdout.flush is important, to ensure that stdout messages are # published in a timely manner sys.stdout.flush() time.sleep(1) print_stuff(3) dview = rc[:] dview import sys import time from IPython.display import clear_output def wait_watching_stdout(ar, dt=1, truncate=1000): while not ar.ready(): stdouts = ar.stdout if not any(stdouts): continue # clear_output doesn't work in plain terminal / script environments clear_output() print '-' * 30 print "%.3fs elapsed" % ar.elapsed print "" for eid, stdout in zip(ar._targets, ar.stdout): if stdout: print "[ stdout %2i ]\n%s" % (eid, stdout[-truncate:]) sys.stdout.flush() time.sleep(dt) ar = dview.apply_async(print_stuff, 5) wait_watching_stdout(ar)