[bitbake-devel,3/4] server/process: Ensure we don't keep looping if some other server is started

Submitted by Richard Purdie on Sept. 4, 2020, 2:44 p.m. | Patch ID: 176049

Details

Message ID 20200904144411.1817481-3-richard.purdie@linuxfoundation.org
State Master Next
Commit 969417c7995ada0e6af132f2d96a2508a06217b3
Headers show

Commit Message

Richard Purdie Sept. 4, 2020, 2:44 p.m.
Shwoing "leftover process" messages when a new server has started and is being
used by some UI is horrible. Compare the PID data from the lockfile to
avoid this (and the ton of confusing log data it generates).

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/server/process.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 2be4588a4f..47e687f4ef 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -266,10 +266,21 @@  class ProcessServer():
         # Finally release the lockfile but warn about other processes holding it open
         lock = self.bitbake_lock
         lockfile = self.bitbake_lock_name
+        with open(lockfile, "r") as f:
+            lockcontents = f.readlines()
+
         lock.close()
         lock = None
 
         while not lock:
+            try:
+                with open(lockfile, "r") as f:
+                    lockcontents2 = f.readlines()
+            except FileNotFoundError:
+                return
+            if lockcontents2 != lockcontents:
+                # A new server was started, the lockfile contents changed, we can exit
+                return
             i = 0
             lock = None
             while not lock and i < 30: