In [2]:
from IPython import parallel
rc = parallel.Client()
dv = rc[:]
rc.ids
Out[2]:
[0, 1, 2, 3]
In [3]:
%px a=5
In [4]:
%px print a
[stdout:0] 5
[stdout:1] 5
[stdout:2] 5
[stdout:3] 5
In [6]:
with dv.sync_imports():
    import numpy, sys, time
importing numpy on engine(s)
importing sys on engine(s)
importing time on engine(s)
In [11]:
%px time.sleep(5)
%px print time.time()
Out[11]:
<AsyncResult: execute>
In [13]:
%pxconfig --block
In [12]:
%pxresult
[stdout:0] 1408657254.6
[stdout:1] 1408657254.6
[stdout:2] 1408657254.6
[stdout:3] 1408657254.6
In [14]:
%%px
%%bash
echo $$
[stdout:0] 4284
[stdout:1] 4283
[stdout:2] 4285
[stdout:3] 4282
In [15]:
dv.scatter('rank', dv.targets)
Out[15]:
<AsyncResult: finished>
In [16]:
%px print rank
[stdout:0] [0]
[stdout:1] [1]
[stdout:2] [2]
[stdout:3] [3]
In [20]:
%%px
%%time
x = numpy.random.rand(8)
b = numpy.dot(x.T,x)
[stdout:0] 
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 66 µs
[stdout:1] 
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 42 µs
[stdout:2] 
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 37 µs
[stdout:3] 
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 31 µs