helloworld.py
14 lines
| 532 B
| text/x-python
|
PythonLexer
Brian E Granger
|
r1337 | """ | ||
A Distributed Hello world | ||||
Ken Kinder <ken@kenkinder.com> | ||||
""" | ||||
Brian E Granger
|
r1338 | from IPython.kernel import client | ||
Brian E Granger
|
r1337 | |||
tc = client.TaskClient() | ||||
mec = client.MultiEngineClient() | ||||
mec.execute('import time') | ||||
Brian E Granger
|
r1396 | hello_taskid = tc.run(client.StringTask('time.sleep(3) ; word = "Hello,"', pull=('word'))) | ||
world_taskid = tc.run(client.StringTask('time.sleep(3) ; word = "World!"', pull=('word'))) | ||||
Brian E Granger
|
r1337 | print "Submitted tasks:", hello_taskid, world_taskid | ||
print tc.get_task_result(hello_taskid,block=True).ns.word, tc.get_task_result(world_taskid,block=True).ns.word | ||||