server/process: Make lockfile handling clearer
PATCH 1/4 server/process: Make lockfile handling clearer
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/server/process.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
lib/bb/server/process.py +6 -4
@@ -239,6 +239,12 @@ class ProcessServer(multiprocessing.Process): while not lock: with bb.utils.timeout(3): lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=True) + if lock: + # We hold the lock so we can remove the file (hide stale pid data) + bb.utils.remove(lockfile) + bb.utils.unlockfile(lock) + return + if not lock: # Some systems may not have lsof available procs = None
@@ -259,10 +265,6 @@ class ProcessServer(multiprocessing.Process): if procs: msg += ":\n%s" % str(procs) print(msg) - return - # We hold the lock so we can remove the file (hide stale pid data) - bb.utils.remove(lockfile) - bb.utils.unlockfile(lock) def idle_commands(self, delay, fds=None): nextsleep = delay
Signature · 1 line
2.19.1
PATCH 2/4 server/process: Handle short reads
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/server/process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/bb/server/process.py +3 -3
@@ -407,9 +407,9 @@ class BitBakeServer(object): except EOFError: # Trap the child exitting/closing the pipe and error out r = None - if not r or r != "ready": + if not r or r[0] != "r": ready.close() - bb.error("Unable to start bitbake server") + bb.error("Unable to start bitbake server (%s)" % str(r)) if os.path.exists(logfile): logstart_re = re.compile(self.start_log_format % ('([0-9]+)', '([0-9-]+ [0-9:.]+)')) started = False
@@ -450,7 +450,7 @@ class BitBakeServer(object): os.close(self.readypipe) writer = ConnectionWriter(self.readypipein) self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) - writer.send("ready") + writer.send("r") writer.close() server.cooker = self.cooker server.server_timeout = self.configuration.server_timeout
Signature · 1 line
2.19.1
PATCH 3/4 process: Flush key output to logs
In reply to Richard PurdieSigned-off-by Richard Purdie <[email protected]>
--- lib/bb/server/process.py | 4 ++++ 1 file changed, 4 insertions(+)
lib/bb/server/process.py +4 -0
@@ -445,6 +445,8 @@ class BitBakeServer(object): def _startServer(self): print(self.start_log_format % (os.getpid(), datetime.datetime.now().strftime(self.start_log_datetime_format))) + sys.stdout.flush() + server = ProcessServer(self.bitbake_lock, self.sock, self.sockname) self.configuration.setServerRegIdleCallback(server.register_idle_function) os.close(self.readypipe)
@@ -456,6 +458,8 @@ class BitBakeServer(object): server.server_timeout = self.configuration.server_timeout server.xmlrpcinterface = self.configuration.xmlrpcinterface print("Started bitbake server pid %d" % os.getpid()) + sys.stdout.flush() + server.start() def connectProcessServer(sockname, featureset):
Signature · 1 line
2.19.1
PATCH 4/4 main: Don't use print() directly, use logger
In reply to Richard PurdieAvoid failures like:
2018-12-04 03:30:56,033 - oe-selftest - INFO - ====================================================================== 2018-12-04 03:30:56,033 - oe-selftest - INFO - FAIL: pkgdata.OePkgdataUtilTests.test_find_path (subunit.RemotedTestCase) 2018-12-04 03:30:56,033 - oe-selftest - INFO - ---------------------------------------------------------------------- 2018-12-04 03:30:56,033 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
[...]
AssertionError: 'Previous bitbake instance shutting down?,[77 chars]xist' != 'ERROR: Unable to find any package produci[14 chars]xist'
- Previous bitbake instance shutting down?, waiting to retry...
ERROR: Unable to find any package producing path /not/exist
We need to use the logger so output is correctly handled in such cases.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/main.py +1 -1
@@ -448,7 +448,7 @@ def setup_bitbake(configParams, configuration, extrafeatures=None): else: logger.info("Reconnecting to bitbake server...") if not os.path.exists(sockname): - print("Previous bitbake instance shutting down?, waiting to retry...") + logger.info("Previous bitbake instance shutting down?, waiting to retry...") i = 0 lock = None # Wait for 5s or until we can get the lock
Signature · 1 line
2.19.1