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

Brian Granger ellisonbg.net at gmail.com
Wed Aug 29 15:41:52 EDT 2007


This page:


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


On 8/29/07, Glen W. Mabey <Glen.Mabey at 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 at scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-dev

More information about the IPython-dev mailing list