From: Scott Gasch Date: Thu, 24 Nov 2022 18:20:35 +0000 (-0800) Subject: Improve error message for logs. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=c5bdf67d6424f11e86f8f61e915dd6636688acf3;hp=6cc5bbeafe0451254bfc5cd3460061b1d3693c2d;p=pyutils.git Improve error message for logs. --- diff --git a/src/pyutils/files/lockfile.py b/src/pyutils/files/lockfile.py index 68f957c..937c863 100644 --- a/src/pyutils/files/lockfile.py +++ b/src/pyutils/files/lockfile.py @@ -176,7 +176,8 @@ class LockFile(contextlib.AbstractContextManager): def __enter__(self): if self.acquire_with_retries(): return self - msg = f"Couldn't acquire {self.lockfile}; giving up." + contents = self._get_lockfile_contents() + msg = f"Couldn't acquire {self.lockfile} after several attempts. It's held by pid={contents.pid} ({contents.commandline}). Giving up." logger.warning(msg) raise LockFileException(msg)