[IPython-dev] finding the number of available engines
MinRK
benjaminrk at gmail.com
Wed Jan 19 14:42:07 EST 2011
mec.queue_status() returns a list of the form:
[
(0, { 'pending' : "execute('a=5')", 'queue' : [ job1,job2,...] } ,
(1, {'pending' : 'None', 'queue' : [] },
...
]
In this case, engine 1 is idle. I don't know why 1's pending is 'None'
instead of None, that seems to be a bug.
So you can see the idle engines with something like:
def idle_engines(mec):
"""return list of engine_ids corresponding to idle engines."""
qs = mec.queue_status()
engines = []
for e_id, status in qs:
if status['queue']:
continue
if not status['pending'] or status['pending'] == 'None':
engines.append(e_id)
return engines
Which would return a list of engine_ids that are idle, the length of which
would of course be the number of idle engines.
-MinRK
On Wed, Jan 19, 2011 at 10:39, Satrajit Ghosh <satra at mit.edu> wrote:
> hi brian and min,
>
> i would like to do something like this:
>
> if num_engines_available() > 2:
> do_x
> else:
> do_y
>
> in 0.10.1 series is there an easy way to query how many idle engines are
> available?
>
> cheers,
>
> satra
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110119/9f302ab6/attachment.html>
More information about the IPython-dev
mailing list