Skip to contentSkip to conversation

cooker: Improve handling errors during parsing when profiling

PATCH New Richard Purdie 1 participant 2 messages May 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cooker: Improve handling errors during parsing when profiling

We've seeing profiling tracebacks when parse errors occur during profiling. Try and avoid these but not processing invalid profiles.

---
 lib/bb/cooker.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
lib/bb/cooker.py +5 -4
index 255b9f199a..673af8daec 100644
@@ -2236,12 +2236,13 @@ class CookerParser(object):
             profiles = []
             for i in self.process_names:
                 logfile = "profile-parse-%s.log" % i
-                if os.path.exists(logfile):
+                if os.path.exists(logfile) and os.path.getsize(logfile):
                     profiles.append(logfile)
 
-            pout = "profile-parse.log.processed"
-            bb.utils.process_profilelog(profiles, pout = pout)
-            print("Processed parsing statistics saved to %s" % (pout))
+            if profiles:
+                pout = "profile-parse.log.processed"
+                bb.utils.process_profilelog(profiles, pout = pout)
+                print("Processed parsing statistics saved to %s" % (pout))
 
     def final_cleanup(self):
         if self.syncthread:
#1 lore raw

PATCH 2/2 bitbake: Drop older python version compatibility code

cooker: We can call multiprocessing close() unconditionally and tweak a comment give 3.8 is now the minimum version.

lib/bb: We can drop the logger addition code only needed before 3.6

asyncrpc/hashserv: Since the minimum version is 3.8, we can drop the conditional code.

---
 lib/bb/__init__.py        | 20 --------------------
 lib/bb/asyncrpc/client.py |  3 +--
 lib/bb/asyncrpc/serv.py   |  3 +--
 lib/bb/cooker.py          |  9 ++++-----
 lib/hashserv/tests.py     |  3 ---
 5 files changed, 6 insertions(+), 32 deletions(-)
lib/bb/__init__.py +0 -20
index b04d4c8a83..574e0de5be 100644
@@ -104,26 +104,6 @@ class BBLoggerAdapter(logging.LoggerAdapter, BBLoggerMixin):
         self.setup_bblogger(logger.name)
         super().__init__(logger, *args, **kwargs)
 
-    if sys.version_info < (3, 6):
-        # These properties were added in Python 3.6. Add them in older versions
-        # for compatibility
-        @property
-        def manager(self):
-            return self.logger.manager
-
-        @manager.setter
-        def manager(self, value):
-            self.logger.manager = value
-
-        @property
-        def name(self):
-            return self.logger.name
-
-        def __repr__(self):
-            logger = self.logger
-            level = logger.getLevelName(logger.getEffectiveLevel())
-            return '<%s %s (%s)>' % (self.__class__.__name__, logger.name, level)
-
 logging.LoggerAdapter = BBLoggerAdapter
 
 logger = logging.getLogger("BitBake")
lib/bb/asyncrpc/client.py +1 -2
index b49de99313..f81ad92f48 100644
@@ -249,8 +249,7 @@ class Client(object):
     def close(self):
         if self.loop:
             self.loop.run_until_complete(self.client.close())
-            if sys.version_info >= (3, 6):
-                self.loop.run_until_complete(self.loop.shutdown_asyncgens())
+            self.loop.run_until_complete(self.loop.shutdown_asyncgens())
             self.loop.close()
         self.loop = None
 
lib/bb/asyncrpc/serv.py +1 -2
index 46d54fb511..667217c5c1 100644
@@ -388,8 +388,7 @@ class AsyncServer(object):
 
             self._serve_forever(tasks)
 
-            if sys.version_info >= (3, 6):
-                self.loop.run_until_complete(self.loop.shutdown_asyncgens())
+            self.loop.run_until_complete(self.loop.shutdown_asyncgens())
             self.loop.close()
 
         queue = multiprocessing.Queue()
lib/bb/cooker.py +4 -5
index 673af8daec..6754f986bf 100644
@@ -1812,8 +1812,8 @@ class CookerCollectFiles(object):
             bb.event.fire(CookerExit(), eventdata)
 
         # We need to track where we look so that we can know when the cache is invalid. There
-        # is no nice way to do this, this is horrid. We intercept the os.listdir()
-        # (or os.scandir() for python 3.6+) calls while we run glob().
+        # is no nice way to do this, this is horrid. We intercept the os.listdir() and os.scandir()
+        # calls while we run glob().
         origlistdir = os.listdir
         if hasattr(os, 'scandir'):
             origscandir = os.scandir
@@ -2224,9 +2224,8 @@ class CookerParser(object):
 
         for process in self.processes:
             process.join()
-            # Added in 3.7, cleans up zombies
-            if hasattr(process, "close"):
-                process.close()
+            # clean up zombies
+            process.close()
 
         bb.codeparser.parser_cache_save()
         bb.codeparser.parser_cache_savemerge()
lib/hashserv/tests.py +0 -3
index 5349cd5867..cf74d9de7e 100644
@@ -94,9 +94,6 @@ class HashEquivalenceTestSetup(object):
         return self.start_client(self.auth_server_address, user["username"], user["token"])
 
     def setUp(self):
-        if sys.version_info < (3, 5, 0):
-            self.skipTest('Python 3.5 or later required')
-
         self.temp_dir = tempfile.TemporaryDirectory(prefix='bb-hashserv')
         self.addCleanup(self.temp_dir.cleanup)