From 8391f47bc9293ed4b13740c747ebc1894cf15f2c Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Sat, 26 Nov 2022 00:48:18 +0000 Subject: [PATCH] stdlib: More helpful message for the filelock error Change-Id: Ib8e3bc9fc145a9604670e8288209ac62bfbd7932 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66091 Maintainer: Bobby Bruce Reviewed-by: Bobby Bruce Tested-by: kokoro --- src/python/gem5/utils/filelock.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/python/gem5/utils/filelock.py b/src/python/gem5/utils/filelock.py index 82e1122bf9..a6798e9f53 100644 --- a/src/python/gem5/utils/filelock.py +++ b/src/python/gem5/utils/filelock.py @@ -69,12 +69,22 @@ class FileLock(object): except OSError as e: if e.errno != errno.EEXIST: raise + solution_message = ( + "This is likely due to the existence" + " of the lock file '{}'. If there's no other process" + " the lock file, you can manually delete the lock file and" + " rerun the script.".format(self.lockfile) + ) if self.timeout is None: raise FileLockException( - "Could not acquire lock on {}".format(self.file_name) + "Could not acquire lock on {}. {}".format( + self.file_name, solution_message + ) ) if (time.time() - start_time) >= self.timeout: - raise FileLockException("Timeout occured.") + raise FileLockException( + "Timeout occured. {}".format(solution_message) + ) time.sleep(self.delay) # self.is_locked = True