All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 4/4 v3] uievent: refactor retry loop
Date: Mon,  4 Jan 2016 11:26:34 +0200	[thread overview]
Message-ID: <1451899594-16564-1-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1451895278-14099-1-git-send-email-ed.bartosh@linux.intel.com>

Replaced 'while' loop with 'for' loop.
Made the code more compact and hopefully more understandable.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/bb/ui/uievent.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
index 19a9301..4670cdb 100644
--- a/bitbake/lib/bb/ui/uievent.py
+++ b/bitbake/lib/bb/ui/uievent.py
@@ -45,27 +45,25 @@ 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))
+            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
+
             import time
             time.sleep(1)
-
-
-        if self.EventHandle == None:
+        else:
             raise Exception(errmsg)
 
         self.server = server
-- 
2.1.4



      reply	other threads:[~2016-01-04 11:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31 16:42 [PATCH 0/4] Improve error reporting for registerEventHandler Ed Bartosh
2015-12-31 16:42 ` [PATCH 1/4] cooker: add state.get_name method Ed Bartosh
2015-12-31 16:42 ` [PATCH 2/4] uievent: add error to registerEventHandler return Ed Bartosh
2015-12-31 16:42 ` [PATCH 3/4] uievent: get rid of EventHandler attribute Ed Bartosh
2015-12-31 16:42 ` [PATCH 4/4] uievent: refactor retry loop Ed Bartosh
2016-01-02 19:29   ` Christopher Larson
2016-01-04  8:14     ` [PATCH v2] " Ed Bartosh
2016-01-04  9:26       ` Ed Bartosh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451899594-16564-1-git-send-email-ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.