[bitbake-devel] [PATCH 4/4] uievent: refactor retry loop
Ed Bartosh
ed.bartosh at linux.intel.com
Thu Dec 31 16:42:16 UTC 2015
Replaced 'while' loop with 'for' loop.
Made the code more compact and hopefully more understandable.
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
index a900555..70a923d 100644
--- a/bitbake/lib/bb/ui/uievent.py
+++ b/bitbake/lib/bb/ui/uievent.py
@@ -45,29 +45,27 @@ class BBUIEventQueue:
server.socket.settimeout(1)
self.EventHandle = None
- count_tries = 0
# the event handler registration may fail here due to cooker being in invalid state
# this is a transient situation, and we should retry a couple of times before
# giving up
- while self.EventHandle == None and count_tries < 5:
+ 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)
+
import time
time.sleep(1)
-
- if self.EventHandle == None:
- raise Exception(errmsg)
-
self.server = server
self.t = threading.Thread()
--
2.1.4
More information about the bitbake-devel
mailing list