diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-01-04 11:26:34 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-06 15:27:35 +0000 |
commit | 05b4fbc947cd2bf9493b74a80d1b58c8ddd480a2 (patch) | |
tree | 7102217bd5347068d9171ed61dfb35506b1d0f7b /bitbake/lib/bb | |
parent | ebc169c36039cc682b28f29688769b5903372a76 (diff) | |
download | poky-05b4fbc947cd2bf9493b74a80d1b58c8ddd480a2.tar.gz |
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>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/ui/uievent.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py index a900555e33..df22e253ca 100644 --- a/bitbake/lib/bb/ui/uievent.py +++ b/bitbake/lib/bb/ui/uievent.py | |||
@@ -45,27 +45,24 @@ class BBUIEventQueue: | |||
45 | server.socket.settimeout(1) | 45 | server.socket.settimeout(1) |
46 | 46 | ||
47 | self.EventHandle = None | 47 | self.EventHandle = None |
48 | count_tries = 0 | ||
49 | 48 | ||
50 | # the event handler registration may fail here due to cooker being in invalid state | 49 | # the event handler registration may fail here due to cooker being in invalid state |
51 | # this is a transient situation, and we should retry a couple of times before | 50 | # this is a transient situation, and we should retry a couple of times before |
52 | # giving up | 51 | # giving up |
53 | 52 | ||
54 | while self.EventHandle == None and count_tries < 5: | 53 | for count_tries in range(5): |
55 | self.EventHandle, error = self.BBServer.registerEventHandler(self.host, self.port) | 54 | self.EventHandle, error = self.BBServer.registerEventHandler(self.host, self.port) |
56 | 55 | ||
57 | if (self.EventHandle != None): | 56 | if self.EventHandle != None: |
58 | break | 57 | break |
59 | 58 | ||
60 | errmsg = "Could not register UI event handler. Error: %s, " \ | 59 | errmsg = "Could not register UI event handler. Error: %s, host %s, "\ |
61 | "host %s, port %d" % (error, self.host, self.port) | 60 | "port %d" % (error, self.host, self.port) |
62 | bb.warn("%s, retry" % errmsg) | 61 | bb.warn("%s, retry" % errmsg) |
63 | count_tries += 1 | 62 | |
64 | import time | 63 | import time |
65 | time.sleep(1) | 64 | time.sleep(1) |
66 | 65 | else: | |
67 | |||
68 | if self.EventHandle == None: | ||
69 | raise Exception(errmsg) | 66 | raise Exception(errmsg) |
70 | 67 | ||
71 | self.server = server | 68 | self.server = server |