* [PATCH v2] uievent: refactor retry loop
@ 2016-01-04 8:12 Ed Bartosh
2016-01-04 8:20 ` Ed Bartosh
0 siblings, 1 reply; 3+ messages in thread
From: Ed Bartosh @ 2016-01-04 8:12 UTC (permalink / raw)
To: openembedded-core; +Cc: CABcZANkw_e36yhZgTVcMdVO5fm7=B4UoN-ZxjKOzNOQTvf3-1g
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 | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
index 19a9301..af239a3 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))
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] uievent: refactor retry loop
2016-01-04 8:12 [PATCH v2] uievent: refactor retry loop Ed Bartosh
@ 2016-01-04 8:20 ` Ed Bartosh
0 siblings, 0 replies; 3+ messages in thread
From: Ed Bartosh @ 2016-01-04 8:20 UTC (permalink / raw)
To: openembedded-core; +Cc: CABcZANkw_e36yhZgTVcMdVO5fm7=B4UoN-ZxjKOzNOQTvf3-1g
wrong list. please ignore.
On Mon, Jan 04, 2016 at 10:12:16AM +0200, Ed Bartosh wrote:
> 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 | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
> index 19a9301..af239a3 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))
> 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
>
--
--
Regards,
Ed
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] uievent: refactor retry loop
2016-01-02 19:29 [PATCH 4/4] " Christopher Larson
@ 2016-01-04 8:14 ` Ed Bartosh
0 siblings, 0 replies; 3+ messages in thread
From: Ed Bartosh @ 2016-01-04 8:14 UTC (permalink / raw)
To: bitbake-devel
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 | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/bitbake/lib/bb/ui/uievent.py b/bitbake/lib/bb/ui/uievent.py
index 19a9301..af239a3 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))
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-04 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 8:12 [PATCH v2] uievent: refactor retry loop Ed Bartosh
2016-01-04 8:20 ` Ed Bartosh
-- strict thread matches above, loose matches on Subject: below --
2016-01-02 19:29 [PATCH 4/4] " Christopher Larson
2016-01-04 8:14 ` [PATCH v2] " Ed Bartosh
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.