cooker: Improve handling errors during parsing when profiling
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.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/cooker.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/bb/cooker.py +5 -4
@@ -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:
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.
Signed-off-by Richard Purdie <[email protected]>
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)