##// END OF EJS Templates
tasks on engines when they die fail instead of hang...
tasks on engines when they die fail instead of hang This is only true in the Python scheduler, and not for any ZMQ scheduler (MUX,control,pure)

File last commit:

r3609:8d078bcc
r3612:4094d44b
Show More
map.py
35 lines | 756 B | text/x-python | PythonLexer
from IPython.zmq.parallel.client import *
client = Client()
@remote(client, block=True)
def square(a):
"""return square of a number"""
return a*a
squares = map(square, range(42))
# but that blocked between each result; not exactly useful
square.block = False
arlist = map(square, range(42))
# submitted very fast
# wait for the results:
squares2 = [ r.get() for r in arlist ]
# now the more convenient @parallel decorator, which has a map method:
@parallel(client, block=False)
def psquare(a):
"""return square of a number"""
return a*a
# this chunks the data into n-negines jobs, not 42 jobs:
ar = psquare.map(range(42))
# wait for the results to be done:
squares3 = ar.get()
print squares == squares2, squares3==squares
# True