<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 31, 2015 at 9:42 AM, Ed Bartosh <span dir="ltr"><<a href="mailto:ed.bartosh@linux.intel.com" target="_blank">ed.bartosh@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":148" class="a3s" style="overflow:hidden">+ for count_tries in range(5):<br>
+<br>
self.EventHandle, error = self.BBServer.registerEventHandler(self.host, self.port)<br>
<br>
- if (self.EventHandle != None):<br>
+ if self.EventHandle != None:<br>
break<br>
<br>
errmsg = "Could not register UI event handler. Error: %s, " \<br>
"host %s, port %d" % (error, self.host, self.port)<br>
<span class="il">bb</span>.warn("%s, retry" % errmsg)<br>
- count_tries += 1<br>
+ if count_tries == 4:<br>
+ raise Exception(errmsg)<br>
+</div></blockquote></div><br></div><div class="gmail_extra">I'd just use the else clause of the for loop here, this is just the sort of case it's good for. The else clause is run when the loop finished / didn't break.<br><br></div><div class="gmail_extra">for count_tries in range(5):<br></div><div class="gmail_extra"> # do stuff<br></div><div class="gmail_extra"> if something:<br></div><div class="gmail_extra"> break<br></div><div class="gmail_extra">else:<br></div><div class="gmail_extra"> # didn't break<br></div><div class="gmail_extra"> raise Exception(errmsg)<br>-- <br><div class="gmail_signature">Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>