[IPython-dev] waiting for a executeAll( ..., block=False) to finish

Brian Granger ellisonbg.net@gmail....
Wed Aug 29 14:41:52 CDT 2007


Yep,

This page:

http://ipython.scipy.org/moin/Parallel_Computing/SawTutorial

Has a section on non-blocking execution that has the details.  Here is
the short story though.

When execute is called with block =False, it returns a PendingResult object:

[15]: pr = rc.executeAll('time.sleep(5)',block=False)

This object has a getResult method that can called at a later moment
in time to get the results.  By default PendingResult.getResult will
block, but it too can be made to not-block (which allows you to poll
for a result) by doing PendingResult.getResult(block=False).  So the
following works:

In [16]: pr.getResult()                                     # now
block for the result
Out[16]:
<Results List>
[0] In [6]: time.sleep(5)
[1] In [4]: time.sleep(5)
[2] In [6]: time.sleep(5)
[3] In [6]: time.sleep(5)

If the call to execute raised an exception, calling getResult will
raise the exception at that point.

Also, it is worth noting that most methods of RemoteController have
this behavior.  The blocking behavior of all methods can be controlled
by setting rc.block = False.  Then all methods (push, pull, execute,
scatter, gather) will return PendingResults objects.

Hope this helps

Brian


On 8/29/07, Glen W. Mabey <Glen.Mabey@swri.org> wrote:
> Hello,
>
> After having called executeAll() with block=False, is there some way to
> wait for it to have completed on all engines?
>
> Thanks,
> Glen
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-dev
>


More information about the IPython-dev mailing list