[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6634/8267] bitbake: event: Queue offline events for the UI



commit 35846a39614815032e4db0d2f26709983a9802d7
Author: Richard Purdie <richard purdie linuxfoundation org>
Date:   Fri Jul 7 15:41:41 2017 +0100

    bitbake: event: Queue offline events for the UI
    
    Messages printed when no UI is connected (e.g. memres) are currently lost.
    Use the existing queue mechanism to queue these until a UI attaches, then
    replay them. This isn't ideal but better than the current situation of
    losing them entirely.
    
    (Bitbake rev: cb241fb8544dfb05646dbae1a1b04e17878a466c)
    
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/lib/bb/event.py          |   11 ++++++++++-
 bitbake/lib/bb/server/process.py |    2 +-
 bitbake/lib/bb/server/xmlrpc.py  |    2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 1462382..d5c5ef3 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -212,6 +212,12 @@ def fire(event, d):
     if worker_fire:
         worker_fire(event, d)
     else:
+        # If messages have been queued up, clear the queue
+        global _uiready, ui_queue
+        if _uiready and ui_queue:
+            for queue_event in ui_queue:
+                fire_ui_handlers(queue_event, d)
+            ui_queue = []
         fire_ui_handlers(event, d)
 
 def fire_from_worker(event, d):
@@ -291,7 +297,10 @@ def register_UIHhandler(handler, mainui=False):
     _ui_logfilters[_ui_handler_seq] = UIEventFilter(level, debug_domains)
     return _ui_handler_seq
 
-def unregister_UIHhandler(handlerNum):
+def unregister_UIHhandler(handlerNum, mainui=False):
+    if mainui:
+        global _uiready
+        _uiready = False
     if handlerNum in _ui_handlers:
         del _ui_handlers[handlerNum]
     return
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 9ca2b69..f8d6767 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -137,7 +137,7 @@ class ProcessServer(Process, BaseImplServer):
                 logger.exception('Running command %s', command)
 
         self.event_queue.close()
-        bb.event.unregister_UIHhandler(self.event_handle.value)
+        bb.event.unregister_UIHhandler(self.event_handle.value, True)
         self.command_channel.close()
         self.cooker.shutdown(True)
         self.quitout.close()
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index a06007f..d0f5a6d 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -125,7 +125,7 @@ class BitBakeServerCommands():
         """
         Unregister a remote UI Event Handler
         """
-        return bb.event.unregister_UIHhandler(handlerNum)
+        return bb.event.unregister_UIHhandler(handlerNum, True)
 
     def runCommand(self, command):
         """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]