File: multiengine2.py

package info (click to toggle)
ipython 0.13.1-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,752 kB
  • sloc: python: 69,537; makefile: 355; lisp: 272; sh: 80; objc: 37
file content (29 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
from __future__ import print_function

import time

from IPython.parallel import Client

#-------------------------------------------------------------------------------
# Setup
#-------------------------------------------------------------------------------

mux = Client()[:]

mux.clear()

mux.block=False

ar1 = mux.apply(time.sleep, 5)
ar2 = mux.push(dict(a=10,b=30,c=range(20000),d='The dog went swimming.'))
ar3 = mux.pull(('a','b','d'), block=False)

print("Try a non-blocking get_result")
ar4 = mux.get_result()

print("Now wait for all the results")
mux.wait([ar1,ar2,ar3,ar4])
print("The last pull got:", ar4.r)