diff mbox series

[2/2] bitbake: Drop older python version compatibility code

Message ID 20240530142654.3095813-2-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 16f4386400f88ba50605307961c248bef09895c1
Headers show
Series [1/2] cooker: Improve handling errors during parsing when profiling | expand

Commit Message

Richard Purdie May 30, 2024, 2:26 p.m. UTC
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 <richard.purdie@linuxfoundation.org>
---
 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(-)
diff mbox series

Patch

diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py
index b04d4c8a83..574e0de5be 100644
--- a/lib/bb/__init__.py
+++ b/lib/bb/__init__.py
@@ -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")
diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index b49de99313..f81ad92f48 100644
--- a/lib/bb/asyncrpc/client.py
+++ b/lib/bb/asyncrpc/client.py
@@ -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
 
diff --git a/lib/bb/asyncrpc/serv.py b/lib/bb/asyncrpc/serv.py
index 46d54fb511..667217c5c1 100644
--- a/lib/bb/asyncrpc/serv.py
+++ b/lib/bb/asyncrpc/serv.py
@@ -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()
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 673af8daec..6754f986bf 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -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()
diff --git a/lib/hashserv/tests.py b/lib/hashserv/tests.py
index 5349cd5867..cf74d9de7e 100644
--- a/lib/hashserv/tests.py
+++ b/lib/hashserv/tests.py
@@ -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)