##// END OF EJS Templates
Fixing more tests and examples after the task, map and @parallel work.
Fixing more tests and examples after the task, map and @parallel work.

File last commit:

r1338:72652d65
r1396:ee81bbeb
Show More
asynctask1.py
32 lines | 774 B | text/x-python | PythonLexer
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 #!/usr/bin/env python
# encoding: utf-8
# This example shows how the AsynTaskClient can be used
Brian E Granger
Fixed most of the examples. A few still don't work, but this is a start.
r1338 # This example is currently broken
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
from twisted.internet import reactor, defer
Brian E Granger
Fixed most of the examples. A few still don't work, but this is a start.
r1338 from IPython.kernel import asyncclient
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
Brian E Granger
Fixed most of the examples. A few still don't work, but this is a start.
r1338 mec = asyncclient.AsyncMultiEngineClient(('localhost', 10105))
tc = asyncclient.AsyncTaskClient(('localhost',10113))
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
cmd1 = """\
a = 5
b = 10*d
c = a*b*d
"""
Brian E Granger
Fixed most of the examples. A few still don't work, but this is a start.
r1338 t1 = asyncclient.Task(cmd1, clear_before=False, clear_after=True, pull=['a','b','c'])
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
d = mec.push(dict(d=30))
def raise_and_print(tr):
tr.raiseException()
print "a, b: ", tr.ns.a, tr.ns.b
return tr
d.addCallback(lambda _: tc.run(t1))
d.addCallback(lambda tid: tc.get_task_result(tid,block=True))
d.addCallback(raise_and_print)
d.addCallback(lambda _: reactor.stop())
reactor.run()