def make_closure(a): """make a function with a closure, and return it""" def has_closure(b): return a * b return has_closure closed = make_closure(5) closed(2) import pickle pickle.dumps(closed) import dill pickle.dumps(closed)[:64] + '...' from IPython import parallel rc = parallel.Client() view = rc.load_balanced_view() view.apply_sync(closed, 3) rc[:].use_dill() view.apply_sync(closed, 3) remote_closure = view.apply_sync(make_closure, 4) remote_closure(5) def outer(a): def inner(b): def inner_again(c): return c * b * a return inner_again return inner view.apply_sync(lambda f: f(3),view.apply_sync(outer, 1)(2)) %px foo = 5 print(rc[:]['foo']) rc[:]['bar'] = lambda : 2 * foo rc[:].apply_sync(parallel.Reference('bar')) %%file testdill.py from IPython.parallel import interactive @interactive class C(object): a = 5 @interactive class D(C): b = 10 @interactive def foo(a): return a * b import testdill v = rc[-1] v['D'] = testdill.D d = v.apply_sync(lambda : D()) print d.a, d.b v['b'] = 10 v.apply_sync(testdill.foo, 5)