Skip to contentSkip to conversation

bb/server/process: Handle EINTR on idle_commands select

PATCH New Aníbal Limón 1 participant 2 messages Jul 17, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bb/server/process: Handle EINTR on idle_commands select

If a signal is sent like SIGWINCH the select could be interrupted so ignore the InterruptError like in XMLRPC server [1].

[1]
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/server/xmlrpc.py#n307

---
 lib/bb/server/process.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/bb/server/process.py +6 -1
index f8d67678..a8ba4681 100644
@@ -186,7 +186,12 @@ class ProcessServer(Process, BaseImplServer):
             nextsleep = self.next_heartbeat - now
 
         if nextsleep is not None:
-            select.select(fds,[],[],nextsleep)
+            try:
+                select.select(fds,[],[],nextsleep)
+            except InterruptedError:
+                # ignore EINTR error, nextsleep only used for wait
+                # certain time
+                pass
 
     def runCommand(self, command):
         """
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 bb/tinfoil: run_command handle busy status in bitbake server

When tinfoil request a command to bitbake is handled in async manner [1], sometimes is this ends on return a Busy status.

This is a workaround a needs to be fixed in proper manner inside bitbake code.

For example when running clientComplete and buildFile is on progress,

ERROR: Function failed: base_do_unpack
Traceback (most recent call last):
File "/home/alimon/repos/poky/scripts/lib/devtool/standard.py", line
797, in modify
initial_rev = _extract_source(srctree, args.keep_temp, args.branch,
False, rd, tinfoil)
File "/home/alimon/repos/poky/scripts/lib/devtool/standard.py", line
562, in _extract_source
runtask(fn, 'unpack')
File "/home/alimon/repos/poky/scripts/lib/devtool/standard.py", line
552, in runtask
raise DevtoolError('Task do_%s failed' % task)
devtool.DevtoolError: Task do_unpack failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/alimon/repos/poky/scripts/devtool", line 351, in <module>
ret = main()
File "/home/alimon/repos/poky/scripts/devtool", line 338, in main
ret = args.func(args, config, basepath, workspace)
File "/home/alimon/repos/poky/scripts/lib/devtool/standard.py", line
864, in modify
tinfoil.shutdown()
File "/home/alimon/repos/poky/bitbake/lib/bb/tinfoil.py", line 427, in
shutdown
self.run_command('clientComplete')
File "/home/alimon/repos/poky/bitbake/lib/bb/tinfoil.py", line 320, in
run_command
raise TinfoilCommandFailed(result[1])
bb.tinfoil.TinfoilCommandFailed: Busy (buildFile in progress)

---
 lib/bb/tinfoil.py | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
lib/bb/tinfoil.py +19 -5
index fb0da622..7f7809ea 100644
@@ -21,6 +21,7 @@ import os
 import sys
 import atexit
 import re
+import time
 from collections import OrderedDict, defaultdict
 
 import bb.cache
@@ -298,7 +299,7 @@ class Tinfoil:
         config_params = TinfoilConfigParameters(config_only=False)
         self.run_actions(config_params)
 
-    def run_command(self, command, *params):
+    def run_command(self, command, *params, ntries=0):
         """
         Run a command on the server (as implemented in bb.command).
         Note that there are two types of command - synchronous and
@@ -315,9 +316,22 @@ class Tinfoil:
         commandline = [command]
         if params:
             commandline.extend(params)
-        result = self.server_connection.connection.runCommand(commandline)
-        if result[1]:
-            raise TinfoilCommandFailed(result[1])
+
+        # XXX: Tinfoil commands are run by Cooker in async mode so gives
+        # some time to get done.
+        result = None
+        while True:
+            result = self.server_connection.connection.runCommand(commandline)
+            if not result[1]:
+                break
+
+            if ntries == 0:
+                raise TinfoilCommandFailed(result[1])
+            elif 'Busy' in result[1]:
+                ntries = ntries - 1
+                time.sleep(1)
+                continue
+
         return result[0]
 
     def set_event_mask(self, eventlist):
@@ -424,7 +438,7 @@ class Tinfoil:
 
     def shutdown(self):
         if self.server_connection:
-            self.run_command('clientComplete')
+            self.run_command('clientComplete', ntries=1)
             _server_connections.remove(self.server_connection)
             bb.event.ui_queue = []
             self.server_connection.terminate()
Signature · 1 line
2.11.0