Fix a bug around the computation of zookeeper lockfile expirations.
authorScott Gasch <[email protected]>
Sat, 1 Apr 2023 18:48:59 +0000 (11:48 -0700)
committerScott Gasch <[email protected]>
Sat, 1 Apr 2023 18:48:59 +0000 (11:48 -0700)
src/pyutils/files/lockfile.py

index 44896c55330c30cb070d5af722ecfb536aab611d..96bc40a0c7badff2854fccf9c131c315a684228b 100644 (file)
@@ -153,10 +153,13 @@ class LockFile(contextlib.AbstractContextManager):
         identifier = f"Lockfile for pid={os.getpid()} on machine {platform.node()}"
         if self.override_command:
             identifier += f" running {self.override_command}"
+        expiration_delta_seconds_from_now = (
+            self.expiration_timestamp - datetime.datetime.now().timestamp()
+        )
         self.zk_lease = zookeeper.RenewableReleasableLease(
             self.zk_client,
             self.lockfile,
-            datetime.timedelta(seconds=self.expiration_timestamp),
+            datetime.timedelta(seconds=expiration_delta_seconds_from_now),
             identifier,
         )
         return self.zk_lease