[IPython-user] IPython1 and TaskClient

Brian Granger ellisonbg.net@gmail....
Wed Apr 9 17:08:06 CDT 2008

> Newbie, just reading some doc :)
> Is it possible to pass functions to a TaskClient? I see it can be passed to
> an Engine, but I see no reference to it in the Task docs.

The way to do this is to also create a MultiEngineClient and use the
push_function method.  The key point is that you can use both the
TaskCliet and MultiEngineClient together and they talk to the same set
of engines underneath.  Thus, any functions you push using
MultiEngineClient will be available to code running in tasks (unless
you set the clearBefore or clearAfter flags in your Taks).

> And is there a way to setup some type of callback for a "finished" task? Or
> the only way to know the completed ones it to check queue_status?

There are two ways to accomplish this:

1) If you are using the standard client module
(ipython1.kernel.client) the TaskClient has a get_task_result method
that has the following signature:

get_task_result(self, taskid, block=False):

If you set block=True, this call will wait until the task finishes and
then return its result.

You can also wait for a set of tasks to be completed by using the
barrier method:

barrier(self, taskids)

here, taskids is simply a list or tuple of task ids.

2) If you really want a more event/callback driven interface, you can
use the asynclient module:


This has an AsynTaskClient that is designed to be used with Twisted's
even loop running.  Then all the methods return deferreds that you can
use the register callbacks on.

Here is an example of that:


(OK, this is not an example of the Task stuff, but you will get the idea)..

Let us know if you have other questions.


> Thnx in advance for the info, and sorry if those are basic questions, just
> read some doc for evaluating IPython1 as the right  tool :)
> _______________________________________________
>  IPython-user mailing list
>  IPython-user@scipy.org
>  http://lists.ipython.scipy.org/mailman/listinfo/ipython-user

More information about the IPython-user mailing list