mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
bitbake: uievent: refactor retry loop
Replaced 'while' loop with 'for' loop. Made the code more compact and hopefully more understandable. (Bitbake rev: 4e1e497c8432536b3522295e5b1284844ccea056) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
ebc169c360
commit
05b4fbc947
@@ -45,27 +45,24 @@ class BBUIEventQueue:
|
|||||||
server.socket.settimeout(1)
|
server.socket.settimeout(1)
|
||||||
|
|
||||||
self.EventHandle = None
|
self.EventHandle = None
|
||||||
count_tries = 0
|
|
||||||
|
|
||||||
# the event handler registration may fail here due to cooker being in invalid state
|
# 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
|
# this is a transient situation, and we should retry a couple of times before
|
||||||
# giving up
|
# 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)
|
self.EventHandle, error = self.BBServer.registerEventHandler(self.host, self.port)
|
||||||
|
|
||||||
if (self.EventHandle != None):
|
if self.EventHandle != None:
|
||||||
break
|
break
|
||||||
|
|
||||||
errmsg = "Could not register UI event handler. Error: %s, " \
|
errmsg = "Could not register UI event handler. Error: %s, host %s, "\
|
||||||
"host %s, port %d" % (error, self.host, self.port)
|
"port %d" % (error, self.host, self.port)
|
||||||
bb.warn("%s, retry" % errmsg)
|
bb.warn("%s, retry" % errmsg)
|
||||||
count_tries += 1
|
|
||||||
import time
|
import time
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
|
||||||
if self.EventHandle == None:
|
|
||||||
raise Exception(errmsg)
|
raise Exception(errmsg)
|
||||||
|
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|||||||
Reference in New Issue
Block a user