[IPython-dev] async taskclient

Vishal Vatsa vishal.vatsa at gmail.com
Fri Jun 20 10:22:08 EDT 2008

2008/6/20 Brian Granger <ellisonbg.net at gmail.com>:
>> 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.addBoth(printer)
>>    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?
> Cheers,
> Brian

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 mailing list