Scale back warnings.warn and add stacklevels= where appropriate.
[python_utils.git] / lockfile.py
index 7f10cc1f5894155c65ca352183afc0ea6d81fa37..8a71ca769900983689479157de0cb3132ab731a9 100644 (file)
@@ -90,7 +90,6 @@ class LockFile(object):
             pass
         msg = f'Could not acquire {self.lockfile}.'
         logger.warning(msg)
-        warnings.warn(msg)
         return False
 
     def acquire_with_retries(
@@ -127,7 +126,6 @@ class LockFile(object):
             return self
         msg = f"Couldn't acquire {self.lockfile}; giving up."
         logger.warning(msg)
-        warnings.warn(msg)
         raise LockFileException(msg)
 
     def __exit__(self, type, value, traceback):
@@ -178,7 +176,6 @@ class LockFile(object):
                     except OSError:
                         msg = f'Lockfile {self.lockfile}\'s pid ({contents.pid}) is stale; force acquiring'
                         logger.warning(msg)
-                        warnings.warn(msg)
                         self.release()
 
                     # Has the lock expiration expired?
@@ -187,7 +184,6 @@ class LockFile(object):
                         if now > contents.expiration_datetime:
                             msg = f'Lockfile {self.lockfile} expiration time has passed; force acquiring'
                             logger.warning(msg)
-                            warnings.warn(msg)
                             self.release()
         except Exception:
             pass