[oe-commits] [bitbake] 04/05: cooker: Improve hash server startup code to avoid exit tracebacks

git at git.openembedded.org git at git.openembedded.org
Mon Aug 12 15:25:31 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit e55ec4d96ac9be99d74bbfbfdd1f3e523275668d
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Mon Aug 12 15:56:20 2019 +0100

    cooker: Improve hash server startup code to avoid exit tracebacks
    
    At exit the hashserv code was causing tracebacks as join() wasn't
    being called from the thread that started the process. Ensure that
    the hashserver is started from the pre_serve hook which is the
    final thread the cooker runs in. This avoids the traceback at the
    expense of some horrific poking into data stores which will ultimately
    need improving through a proper API.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/cooker.py         | 29 +++++++++++++++++------------
 lib/hashserv/__init__.py |  1 +
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index ec1b35d..0607fcc 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -371,22 +371,10 @@ class BBCooker:
 
         self.data.setVar('BB_CMDLINE', self.ui_cmdline)
 
-        if self.data.getVar("BB_HASHSERVE") == "localhost:0":
-            if not self.hashserv:
-                dbfile = (self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")) + "/hashserv.db"
-                self.hashserv = hashserv.create_server(('localhost', 0), dbfile, '')
-                self.hashservport = "localhost:" + str(self.hashserv.server_port)
-                self.hashserv.process = multiprocessing.Process(target=self.hashserv.serve_forever)
-                self.hashserv.process.daemon = True
-                self.hashserv.process.start()
-            self.data.setVar("BB_HASHSERVE", self.hashservport)
-
         #
         # Copy of the data store which has been expanded.
         # Used for firing events and accessing variables where expansion needs to be accounted for
         #
-        bb.parse.init_parser(self.data)
-
         if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
             self.disableDataTracking()
 
@@ -404,6 +392,22 @@ class BBCooker:
         except prserv.serv.PRServiceConfigError as e:
             bb.fatal("Unable to start PR Server, exitting")
 
+        if self.data.getVar("BB_HASHSERVE") == "localhost:0":
+            if not self.hashserv:
+                dbfile = (self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")) + "/hashserv.db"
+                self.hashserv = hashserv.create_server(('localhost', 0), dbfile, '')
+                self.hashservport = "localhost:" + str(self.hashserv.server_port)
+                self.hashserv.process = multiprocessing.Process(target=self.hashserv.serve_forever)
+                self.hashserv.process.daemon = True
+                self.hashserv.process.start()
+            self.data.setVar("BB_HASHSERVE", self.hashservport)
+            self.databuilder.origdata.setVar("BB_HASHSERVE", self.hashservport)
+            self.databuilder.data.setVar("BB_HASHSERVE", self.hashservport)
+            for mc in self.databuilder.mcdata:
+                self.databuilder.mcdata[mc].setVar("BB_HASHSERVE", self.hashservport)
+
+        bb.parse.init_parser(self.data)
+
     def enableDataTracking(self):
         self.configuration.tracking = True
         if hasattr(self, "data"):
@@ -1677,6 +1681,7 @@ class BBCooker:
 
     def reset(self):
         self.initConfigurationData()
+        self.handlePRServ()
 
     def clientComplete(self):
         """Called when the client is done using the server"""
diff --git a/lib/hashserv/__init__.py b/lib/hashserv/__init__.py
index 1d5e08e..55966e7 100644
--- a/lib/hashserv/__init__.py
+++ b/lib/hashserv/__init__.py
@@ -151,6 +151,7 @@ class ThreadedHTTPServer(HTTPServer):
 
         signal.signal(signal.SIGTERM, self.sigterm_exception)
         super().serve_forever()
+        os._exit(0)
 
     def sigterm_exception(self, signum, stackframe):
         self.server_close()

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list