Skip to contentSkip to conversation

improved killing bitbake server

PATCH Superseded Ed Bartosh 2 participants 7 messages Jan 5, 2016

lore
Share & tools
lore

Ed Bartosh

author
#0 lore raw

cover improved killing bitbake server

Hi,

Setup of event queue includes registering of UI handler. This operation can fail when cooker is busy. However, there is no need in registering UI handler for terminating the server.

This patchset makes server terminating to work without setting up the event queue and registering UI handler. This should make terminating server to work more reliably.

This should also help Toaster backend to restart bitbake server and observer without getting "Could not register UI event handler" errors.

Ed Bartosh (2):
bitbake: xmplrpc: split connect method
bitbake: main: kill server without queue setup

 bitbake/lib/bb/main.py          | 12 +++++++-----
 bitbake/lib/bb/server/xmlrpc.py |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

--
Regards,
Ed

author
#1 lore raw

PATCH 1/2 bitbake: xmplrpc: split connect method

Current code in connect method sets up event queue, which requires registering UI handler. This functionality may not be needed for some operations, e.g. for server termination.

Moved functionality of setting up event queue in from 'connect' method to 'setupEventQueue' in BitBakeXMLRPCServerConnection class.

bitbake/lib/bb/main.py +1 -0
index c8530fc..dd04393 100755
@@ -403,6 +403,7 @@ def bitbake_main(configParams, configuration):
     if not configParams.server_only:
         try:
             server_connection = server.establishConnection(featureset)
+            server_connection.setupEventQueue()
         except Exception as e:
             bb.fatal("Could not connect to server %s: %s" % (configParams.remote_server, str(e)))
 
bitbake/lib/bb/server/xmlrpc.py +2 -2
index 17eb28b..1ceca51 100644
@@ -302,7 +302,9 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
             return None
 
         self.transport.set_connection_token(token)
+        return self
 
+    def setupEventQueue(self):
         self.events = uievent.BBUIEventQueue(self.connection, self.clientinfo)
         for event in bb.event.ui_queue:
             self.events.queue_event(event)
@@ -314,8 +316,6 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
             # no need to log it here, the error shall be sent to the client
             raise BaseException(error)
 
-        return self
-
     def removeClient(self):
         if not self.observer_only:
             self.connection.removeClient()
Signature · 1 line
2.1.4
author
#6 lore raw

PATCH 2/2 bitbake: main: kill server without queue setup

In reply to Ed Bartosh

Setup of event queue includes registering of UI handler. This operation can fail when cooker is busy. However, there is no need in registering UI handler for terminating the server.

Moved the call of connection.terminateServer before setting up of the event queue. This should make terminating server to work more reliably as it doesn't depend on setting up the event queue and registering UI handler anymore.

This should also help Toaster backend to restart bitbake server and observer without getting "Could not register UI event handler" errors.

[YOCTO #8776]

bitbake/lib/bb/main.py +7 -6
index dd04393..c0ae38a 100755
@@ -403,10 +403,16 @@ def bitbake_main(configParams, configuration):
     if not configParams.server_only:
         try:
             server_connection = server.establishConnection(featureset)
-            server_connection.setupEventQueue()
         except Exception as e:
             bb.fatal("Could not connect to server %s: %s" % (configParams.remote_server, str(e)))
 
+        if configParams.kill_server:
+            server_connection.connection.terminateServer()
+            bb.event.ui_queue = []
+            return 0
+
+        server_connection.setupEventQueue()
+
         # Restore the environment in case the UI needs it
         for k in cleanedvars:
             os.environ[k] = cleanedvars[k]
@@ -418,11 +424,6 @@ def bitbake_main(configParams, configuration):
             server_connection.terminate()
             return 0
 
-        if configParams.kill_server:
-            server_connection.connection.terminateServer()
-            bb.event.ui_queue = []
-            return 0
-
         try:
             return ui_module.main(server_connection.connection, server_connection.events, configParams)
         finally:
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 1/2] bitbake: xmplrpc: split connect method

In reply to Ed Bartosh
Quoted 3 lines · Ed Bartosh

Moved functionality of setting up event queue in from 'connect' method to 'setupEventQueue' in BitBakeXMLRPCServerConnection class.

Bitbake fails for me now:

Traceback (most recent call last):
File "/home/ross/Yocto/poky/bitbake/bin/bitbake", line 45, in <module>
cookerdata.CookerConfiguration()))
File "/home/ross/Yocto/poky/bitbake/lib/bb/main.py", line 414, in
bitbake_main
server_connection.setupEventQueue()
AttributeError: BitBakeProcessServerConnection instance has no attribute 'setupEventQueue'

Ross

author
#3 lore raw

v2 cover improved killing bitbake server

Hi,

Setup of event queue includes registering of UI handler. This operation can fail when cooker is busy. However, there is no need in registering UI handler for terminating the server.

This patchset makes server terminating to work without setting up the event queue and registering UI handler. This should make terminating server to work more reliably.

This should also help Toaster backend to restart bitbake server and observer without getting "Could not register UI event handler" errors.

Changes in v2: Fixed AttributeError: BitBakeProcessServerConnection instance has no attribute 'setupEventQueue'

Ed Bartosh (2):
bitbake: xmplrpc: split connect method
bitbake: main: kill server without queue setup

 bitbake/lib/bb/main.py            | 12 +++++++-----
 bitbake/lib/bb/server/__init__.py |  3 +++
 bitbake/lib/bb/server/xmlrpc.py   |  4 ++--
 3 files changed, 12 insertions(+), 7 deletions(-)

--
Regards,
Ed

author
#4 lore raw

PATCH v2 1/2 bitbake: xmplrpc: split connect method

Current code in connect method sets up event queue, which requires registering UI handler. This functionality may not be needed for some operations, e.g. for server termination.

Moved functionality of setting up event queue in from 'connect' method to 'setupEventQueue' in BitBakeXMLRPCServerConnection class.

bitbake/lib/bb/main.py +1 -0
index c8530fc..dd04393 100755
@@ -403,6 +403,7 @@ def bitbake_main(configParams, configuration):
     if not configParams.server_only:
         try:
             server_connection = server.establishConnection(featureset)
+            server_connection.setupEventQueue()
         except Exception as e:
             bb.fatal("Could not connect to server %s: %s" % (configParams.remote_server, str(e)))
 
bitbake/lib/bb/server/__init__.py +3 -0
index da5e480..538a633 100644
@@ -63,6 +63,9 @@ class BitBakeBaseServerConnection():
     def terminate(self):
         pass
 
+    def setupEventQueue(self):
+        pass
+
 
 """ BitBakeBaseServer class is the common ancestor to all Bitbake servers
 
bitbake/lib/bb/server/xmlrpc.py +2 -2
index 17eb28b..1ceca51 100644
@@ -302,7 +302,9 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
             return None
 
         self.transport.set_connection_token(token)
+        return self
 
+    def setupEventQueue(self):
         self.events = uievent.BBUIEventQueue(self.connection, self.clientinfo)
         for event in bb.event.ui_queue:
             self.events.queue_event(event)
@@ -314,8 +316,6 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
             # no need to log it here, the error shall be sent to the client
             raise BaseException(error)
 
-        return self
-
     def removeClient(self):
         if not self.observer_only:
             self.connection.removeClient()
Signature · 1 line
2.1.4
author
#5 lore raw

PATCH v2 2/2 bitbake: main: kill server without queue setup

In reply to Ed Bartosh

Setup of event queue includes registering of UI handler. This operation can fail when cooker is busy. However, there is no need in registering UI handler for terminating the server.

Moved the call of connection.terminateServer before setting up of the event queue. This should make terminating server to work more reliably as it doesn't depend on setting up the event queue and registering UI handler anymore.

This should also help Toaster backend to restart bitbake server and observer without getting "Could not register UI event handler" errors.

[YOCTO #8776]

bitbake/lib/bb/main.py +7 -6
index dd04393..c0ae38a 100755
@@ -403,10 +403,16 @@ def bitbake_main(configParams, configuration):
     if not configParams.server_only:
         try:
             server_connection = server.establishConnection(featureset)
-            server_connection.setupEventQueue()
         except Exception as e:
             bb.fatal("Could not connect to server %s: %s" % (configParams.remote_server, str(e)))
 
+        if configParams.kill_server:
+            server_connection.connection.terminateServer()
+            bb.event.ui_queue = []
+            return 0
+
+        server_connection.setupEventQueue()
+
         # Restore the environment in case the UI needs it
         for k in cleanedvars:
             os.environ[k] = cleanedvars[k]
@@ -418,11 +424,6 @@ def bitbake_main(configParams, configuration):
             server_connection.terminate()
             return 0
 
-        if configParams.kill_server:
-            server_connection.connection.terminateServer()
-            bb.event.ui_queue = []
-            return 0
-
         try:
             return ui_module.main(server_connection.connection, server_connection.events, configParams)
         finally:
Signature · 1 line
2.1.4