hi min,<br><br>i've run into a related problem. i'm trying to run code on an engine that can itself spawn new tasks, but i can't seem to execute function below on an engine. it just doesn't return if you call this through the taskclient in blocking mode. <br>
<br>it seems to block in the request for the task client and multiengine client.<br>
<br>cheers,<br><br>satra<br><br>-----<br>def get_ipy_clients():<br> """Get ipython clients<br><br> Returns client, taskclient and multiengineclient<br> """<br> ipyclient = None<br>
taskclient = None<br> mecclient = None<br> try:<br> name = 'IPython.kernel.client'<br> __import__(name)<br> ipyclient = sys.modules[name]<br> except ImportError:<br> warn("Ipython kernel not found. Parallel execution will be" \<br>
"unavailable", ImportWarning)<br> if ipyclient:<br> try:<br> taskclient = ipyclient.TaskClient()<br> mecclient = ipyclient.MultiEngineClient()<br> except Exception, e:<br>
if isinstance(e, ConnectionRefusedError):<br> warn("No clients found, running serially for now.")<br> if isinstance(e, ValueError):<br> warn("Ipython kernel not installed")<br>
return ipyclient, taskclient, mecclient<br>------<br><br>
<br><br><div class="gmail_quote">On Wed, Jan 19, 2011 at 2:42 PM, MinRK <span dir="ltr"><<a href="mailto:benjaminrk@gmail.com" target="_blank">benjaminrk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
mec.queue_status() returns a list of the form:<div>[ </div><div> (0, { 'pending' : "execute('a=5')", 'queue' : [ job1,job2,...] } ,</div><div> (1, {'pending' : 'None', 'queue' : [] },</div>
<div> ...</div><div>]<br><div><br></div><div>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.</div><div><br></div><div>So you can see the idle engines with something like:</div>
<div><div><br></div><div>def idle_engines(mec):</div><div> """return list of engine_ids corresponding to idle engines."""</div><div> qs = mec.queue_status()</div><div> engines = []</div>
<div> for e_id, status in qs:</div><div> if status['queue']:</div><div> continue</div><div> if not status['pending'] or status['pending'] == 'None':</div><div> engines.append(e_id)</div>
<div> return engines</div></div><div><br></div><div>Which would return a list of engine_ids that are idle, the length of which would of course be the number of idle engines.</div><div><br></div><div>-MinRK<br>
<br><br><div class="gmail_quote"><div><div></div><div>On Wed, Jan 19, 2011 at 10:39, Satrajit Ghosh <span dir="ltr"><<a href="mailto:satra@mit.edu" target="_blank">satra@mit.edu</a>></span> wrote:<br></div>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div>
<div>hi brian and min,<br><br>i would like to do something like this:<br><br>if num_engines_available() > 2:<br> do_x<br>else: <br> do_y<br><br></div>in 0.10.1 series is there an easy way to query how many idle engines are available? <br>
<br clear="all">cheers,<br><br>satra<br><br>
<br></div></div>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br>