[IPython-dev] async taskclient
Fri Jun 20 09:22:08 CDT 2008
2008/6/20 Brian Granger <firstname.lastname@example.org>:
>> I have a question about how to use the async task client.
>> Given the following code:
>> def job_runner(code):
>> def submit(task_client, cmd):
>> t1 = Task(cmd, clear_before=True, clear_after=True, pull=['a'])
>> d = task_client.run(t1)
>> d.addCallback(lambda tid:
>> task_client.get_task_result(taskid=tid, block=True))
>> d = asyncclient.get_task_client()
>> d.addCallback(lambda tc: submit(tc, code))
>> where code is some python code in a string.
>> Is it ok to get a new instance of async task client for every
>> job I want to submit?
> You can do this but for each new client there will be a new connection
> to the controller. Thus it is best for performance reasons to use a
> single TaskClient instance for all of your tasks in a sessions.
> Is there a reason you want to use a TaskClient for each task?
I tried to reuse the defered that get_task_client() gets me but I was not sure
how to reuse the async task client. Would you have a suggestion on how
to go about this?
More information about the IPython-dev