diff options
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/server/process.py | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index 6d936ed457..973bc45251 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py | |||
| @@ -266,34 +266,37 @@ class ProcessServer(): | |||
| 266 | lock = None | 266 | lock = None |
| 267 | 267 | ||
| 268 | while not lock: | 268 | while not lock: |
| 269 | with bb.utils.timeout(3): | 269 | i = 0 |
| 270 | lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=True) | 270 | lock = None |
| 271 | if lock: | 271 | while not lock and i < 30: |
| 272 | # We hold the lock so we can remove the file (hide stale pid data) | 272 | time.sleep(0.1) |
| 273 | # via unlockfile. | 273 | _, lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False) |
| 274 | bb.utils.unlockfile(lock) | 274 | i += 1 |
| 275 | return | 275 | if lock: |
| 276 | 276 | # We hold the lock so we can remove the file (hide stale pid data) | |
| 277 | if not lock: | 277 | # via unlockfile. |
| 278 | # Some systems may not have lsof available | 278 | bb.utils.unlockfile(lock) |
| 279 | procs = None | 279 | return |
| 280 | if not lock: | ||
| 281 | # Some systems may not have lsof available | ||
| 282 | procs = None | ||
| 283 | try: | ||
| 284 | procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) | ||
| 285 | except OSError as e: | ||
| 286 | if e.errno != errno.ENOENT: | ||
| 287 | raise | ||
| 288 | if procs is None: | ||
| 289 | # Fall back to fuser if lsof is unavailable | ||
| 280 | try: | 290 | try: |
| 281 | procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) | 291 | procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) |
| 282 | except OSError as e: | 292 | except OSError as e: |
| 283 | if e.errno != errno.ENOENT: | 293 | if e.errno != errno.ENOENT: |
| 284 | raise | 294 | raise |
| 285 | if procs is None: | 295 | |
| 286 | # Fall back to fuser if lsof is unavailable | 296 | msg = "Delaying shutdown due to active processes which appear to be holding bitbake.lock" |
| 287 | try: | 297 | if procs: |
| 288 | procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) | 298 | msg += ":\n%s" % str(procs) |
| 289 | except OSError as e: | 299 | print(msg) |
| 290 | if e.errno != errno.ENOENT: | ||
| 291 | raise | ||
| 292 | |||
| 293 | msg = "Delaying shutdown due to active processes which appear to be holding bitbake.lock" | ||
| 294 | if procs: | ||
| 295 | msg += ":\n%s" % str(procs) | ||
| 296 | print(msg) | ||
| 297 | 300 | ||
| 298 | def idle_commands(self, delay, fds=None): | 301 | def idle_commands(self, delay, fds=None): |
| 299 | nextsleep = delay | 302 | nextsleep = delay |
