Skip to contentSkip to conversation

server/process: Fix waitEvent() calls with 0 timeout

PATCH In review Richard Purdie 2 participants 2 messages Jul 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 server/process: Fix waitEvent() calls with 0 timeout

You might think Queue.Queue.get(True, 0) would return an event immediately if present and otherwise return. It doesn't, it immediately "times out" and returns with nothing from the queue.

The behaviour we want is not to wait but return anything present which is what .get(False) does so map to this.

This fixes some odd behaviour observed in some of the tinfoil selftests.

---
 lib/bb/server/process.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/server/process.py +2 -0
index c3c1450..9ca2b69 100644
@@ -253,6 +253,8 @@ class ProcessEventQueue(multiprocessing.queues.Queue):
         try:
             if not self.server.is_alive():
                 return self.getEvent()
+            if timeout == 0:
+                return self.get(False)
             return self.get(True, timeout)
         except Empty:
             return None
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Richard Purdie

You might think Queue.Queue.get(True, 0) would return an event immediately if present and otherwise return. It doesn't, it immediately "times out" and returns with nothing from the queue.

… wow, that’s .. not intuitive at all.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics