diff mbox series

server/process: Merge a function to simplfy code

Message ID 20241105165233.2842065-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit e5ac26a0e1779df1da3277bf48899c8f7642f1f8
Headers show
Series server/process: Merge a function to simplfy code | expand

Commit Message

Richard Purdie Nov. 5, 2024, 4:52 p.m. UTC
Keeping this code separate just makes the code harder to understand,
merge them.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/server/process.py | 42 +++++++++++++++-------------------------
 1 file changed, 16 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 76b189291d..ad4035a738 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -321,7 +321,22 @@  class ProcessServer():
                     bb.warn('Ignoring invalid BB_SERVER_TIMEOUT=%s, must be a float specifying seconds.' % self.timeout)
                 seendata = True
 
-            ready = self.idle_commands(.1, fds)
+            if not self.idle:
+                self.idle = threading.Thread(target=self.idle_thread)
+                self.idle.start()
+            elif self.idle and not self.idle.is_alive():
+                serverlog("Idle thread terminated, main thread exiting too")
+                bb.error("Idle thread terminated, main thread exiting too")
+                self.quit = True
+
+            nextsleep = 0.1
+            if self.xmlrpc:
+                nextsleep = self.xmlrpc.get_timeout(nextsleep)
+            try:
+                ready = select.select(fds,[],[],nextsleep)[0]
+            except InterruptedError:
+                # Ignore EINTR
+                ready = []
 
         if self.idle:
             self.idle.join()
@@ -485,31 +500,6 @@  class ProcessServer():
             if nextsleep is not None:
                 select.select(fds,[],[],nextsleep)[0]
 
-    def idle_commands(self, delay, fds=None):
-        nextsleep = delay
-        if not fds:
-            fds = []
-
-        if not self.idle:
-            self.idle = threading.Thread(target=self.idle_thread)
-            self.idle.start()
-        elif self.idle and not self.idle.is_alive():
-            serverlog("Idle thread terminated, main thread exiting too")
-            bb.error("Idle thread terminated, main thread exiting too")
-            self.quit = True
-
-        if nextsleep is not None:
-            if self.xmlrpc:
-                nextsleep = self.xmlrpc.get_timeout(nextsleep)
-            try:
-                return select.select(fds,[],[],nextsleep)[0]
-            except InterruptedError:
-                # Ignore EINTR
-                return []
-        else:
-            return select.select(fds,[],[],0)[0]
-
-
 class ServerCommunicator():
     def __init__(self, connection, recv):
         self.connection = connection