[edk2-devel] [PATCH 1/3] build: Fix python3.10 threading DeprecationWarnings

Cole crobinso at redhat.com
Fri Jul 23 20:02:26 UTC 2021


threading camelCase functions have preferred alternatives since
python2.6. python3.10 has started emitting DeprecationWarnings
for them

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 BaseTools/Source/Python/build/build.py | 48 +++++++++++++-------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 3e4d83409f..02b4898924 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -197,7 +197,7 @@ def ReadMessage(From, To, ExitFlag,MemTo=None):
                 To(LineStr)

         else:

             break

-        if ExitFlag.isSet():

+        if ExitFlag.is_set():

             break

 

 class MakeSubProc(Popen):

@@ -241,8 +241,8 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto = None):
         EndOfProcedure.clear()

         if Proc.stdout:

             StdOutThread = Thread(target=ReadMessage, args=(Proc.stdout, EdkLogger.info, EndOfProcedure,Proc.ProcOut))

-            StdOutThread.setName("STDOUT-Redirector")

-            StdOutThread.setDaemon(False)

+            StdOutThread.name = "STDOUT-Redirector"

+            StdOutThread.daemon = False

             StdOutThread.start()

 

 

@@ -433,8 +433,8 @@ class BuildTask:
     @staticmethod

     def StartScheduler(MaxThreadNumber, ExitFlag):

         SchedulerThread = Thread(target=BuildTask.Scheduler, args=(MaxThreadNumber, ExitFlag))

-        SchedulerThread.setName("Build-Task-Scheduler")

-        SchedulerThread.setDaemon(False)

+        SchedulerThread.name = "Build-Task-Scheduler"

+        SchedulerThread.daemon = False

         SchedulerThread.start()

         # wait for the scheduler to be started, especially useful in Linux

         while not BuildTask.IsOnGoing():

@@ -456,7 +456,7 @@ class BuildTask:
             # indicated to do so, or there's error in running thread

             #

             while (len(BuildTask._PendingQueue) > 0 or len(BuildTask._ReadyQueue) > 0 \

-                   or not ExitFlag.isSet()) and not BuildTask._ErrorFlag.isSet():

+                   or not ExitFlag.is_set()) and not BuildTask._ErrorFlag.is_set():

                 EdkLogger.debug(EdkLogger.DEBUG_8, "Pending Queue (%d), Ready Queue (%d)"

                                 % (len(BuildTask._PendingQueue), len(BuildTask._ReadyQueue)))

 

@@ -474,7 +474,7 @@ class BuildTask:
                 BuildTask._PendingQueueLock.release()

 

                 # launch build thread until the maximum number of threads is reached

-                while not BuildTask._ErrorFlag.isSet():

+                while not BuildTask._ErrorFlag.is_set():

                     # empty ready queue, do nothing further

                     if len(BuildTask._ReadyQueue) == 0:

                         break

@@ -498,12 +498,12 @@ class BuildTask:
                 time.sleep(0.01)

 

             # wait for all running threads exit

-            if BuildTask._ErrorFlag.isSet():

+            if BuildTask._ErrorFlag.is_set():

                 EdkLogger.quiet("\nWaiting for all build threads exit...")

-            # while not BuildTask._ErrorFlag.isSet() and \

+            # while not BuildTask._ErrorFlag.is_set() and \

             while len(BuildTask._RunningQueue) > 0:

                 EdkLogger.verbose("Waiting for thread ending...(%d)" % len(BuildTask._RunningQueue))

-                EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate()))

+                EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.name for Th in threading.enumerate()))

                 # avoid tense loop

                 time.sleep(0.1)

         except BaseException as X:

@@ -531,7 +531,7 @@ class BuildTask:
     #

     @staticmethod

     def IsOnGoing():

-        return not BuildTask._SchedulerStopped.isSet()

+        return not BuildTask._SchedulerStopped.is_set()

 

     ## Abort the build

     @staticmethod

@@ -547,7 +547,7 @@ class BuildTask:
     #

     @staticmethod

     def HasError():

-        return BuildTask._ErrorFlag.isSet()

+        return BuildTask._ErrorFlag.is_set()

 

     ## Get error message in running thread

     #

@@ -644,7 +644,7 @@ class BuildTask:
             # TRICK: hide the output of threads left running, so that the user can

             #        catch the error message easily

             #

-            if not BuildTask._ErrorFlag.isSet():

+            if not BuildTask._ErrorFlag.is_set():

                 GlobalData.gBuildingModule = "%s [%s, %s, %s]" % (str(self.BuildItem.BuildObject),

                                                                   self.BuildItem.BuildObject.Arch,

                                                                   self.BuildItem.BuildObject.ToolChain,

@@ -653,7 +653,7 @@ class BuildTask:
             EdkLogger.SetLevel(EdkLogger.ERROR)

             BuildTask._ErrorFlag.set()

             BuildTask._ErrorMessage = "%s broken\n    %s [%s]" % \

-                                      (threading.currentThread().getName(), Command, WorkingDir)

+                                      (threading.current_thread().name, Command, WorkingDir)

 

         # indicate there's a thread is available for another build task

         BuildTask._RunningQueueLock.acquire()

@@ -667,8 +667,8 @@ class BuildTask:
         EdkLogger.quiet("Building ... %s" % repr(self.BuildItem))

         Command = self.BuildItem.BuildCommand + [self.BuildItem.Target]

         self.BuildTread = Thread(target=self._CommandThread, args=(Command, self.BuildItem.WorkingDir))

-        self.BuildTread.setName("build thread")

-        self.BuildTread.setDaemon(False)

+        self.BuildTread.name = "build thread"

+        self.BuildTread.daemon = False

         self.BuildTread.start()

 

 ## The class contains the information related to EFI image

@@ -1177,14 +1177,14 @@ class Build():
             EndOfProcedure.clear()

             if Process.stdout:

                 StdOutThread = Thread(target=ReadMessage, args=(Process.stdout, EdkLogger.info, EndOfProcedure))

-                StdOutThread.setName("STDOUT-Redirector")

-                StdOutThread.setDaemon(False)

+                StdOutThread.name = "STDOUT-Redirector"

+                StdOutThread.daemon = False

                 StdOutThread.start()

 

             if Process.stderr:

                 StdErrThread = Thread(target=ReadMessage, args=(Process.stderr, EdkLogger.quiet, EndOfProcedure))

-                StdErrThread.setName("STDERR-Redirector")

-                StdErrThread.setDaemon(False)

+                StdErrThread.name = "STDERR-Redirector"

+                StdErrThread.daemon = False

                 StdErrThread.start()

             # waiting for program exit

             Process.wait()

@@ -1217,14 +1217,14 @@ class Build():
             EndOfProcedure.clear()

             if Process.stdout:

                 StdOutThread = Thread(target=ReadMessage, args=(Process.stdout, EdkLogger.info, EndOfProcedure))

-                StdOutThread.setName("STDOUT-Redirector")

-                StdOutThread.setDaemon(False)

+                StdOutThread.name = "STDOUT-Redirector"

+                StdOutThread.daemon = False

                 StdOutThread.start()

 

             if Process.stderr:

                 StdErrThread = Thread(target=ReadMessage, args=(Process.stderr, EdkLogger.quiet, EndOfProcedure))

-                StdErrThread.setName("STDERR-Redirector")

-                StdErrThread.setDaemon(False)

+                StdErrThread.name = "STDERR-Redirector"

+                StdErrThread.daemon = False

                 StdErrThread.start()

             # waiting for program exit

             Process.wait()

-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78144): https://edk2.groups.io/g/devel/message/78144
Mute This Topic: https://groups.io/mt/84409129/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list