##// END OF EJS Templates
The refactoring of the Task system is nearly complete. Now there are...
The refactoring of the Task system is nearly complete. Now there are multiple types of tasks including `StringTask` and `MapTask`. Each task type is responsible for running itself and processing its own result. This makes it much easier for people to create new task types. Also, the map and parallel function support has been completely refactored and improved. This includes a map and parallel function implementation for the task controller as well as a @parallel decorator.

File last commit:

r1395:1feaf0a3
r1395:1feaf0a3
Show More
taskmap.py
18 lines | 490 B | text/x-python | PythonLexer
from IPython.kernel import client
tc = client.TaskClient()
result = tc.map(lambda x: 2*x, range(10))
print "Simple, default map: ", result
m = tc.mapper(block=False, clear_after=True, clear_before=True)
tids = m.map(lambda x: 2*x, range(10))
print "Submitted tasks, got ids: ", tids
tc.barrier(tids)
result = [tc.get_task_result(tid) for tid in tids]
print "Using a mapper: ", result
@tc.parallel()
def f(x): return 2*x
result = f(range(10))
print "Using a parallel function: ", result