[bitbake-devel] [PATCH 4/4] uievent: refactor retry loop
Christopher Larson
clarson at kergoth.com
Sat Jan 2 19:29:57 UTC 2016
On Thu, Dec 31, 2015 at 9:42 AM, Ed Bartosh <ed.bartosh at linux.intel.com>
wrote:
> + for count_tries in range(5):
> +
> self.EventHandle, error =
> self.BBServer.registerEventHandler(self.host, self.port)
>
> - if (self.EventHandle != None):
> + if self.EventHandle != None:
> break
>
> errmsg = "Could not register UI event handler. Error: %s, " \
> "host %s, port %d" % (error, self.host, self.port)
> bb.warn("%s, retry" % errmsg)
> - count_tries += 1
> + if count_tries == 4:
> + raise Exception(errmsg)
> +
>
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.
for count_tries in range(5):
# do stuff
if something:
break
else:
# didn't break
raise Exception(errmsg)
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20160102/03b933f4/attachment-0002.html>
More information about the bitbake-devel
mailing list