stdlib: More helpful message for the filelock error

Change-Id: Ib8e3bc9fc145a9604670e8288209ac62bfbd7932
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66091
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Hoa Nguyen
2022-11-26 00:48:18 +00:00
parent 770b84c2ee
commit 8391f47bc9

View File

@@ -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