From 2bfc6713b013c9c01561e25fa8f7f13877a026df Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Sat, 1 Apr 2023 11:48:59 -0700 Subject: [PATCH] Fix a bug around the computation of zookeeper lockfile expirations. --- src/pyutils/files/lockfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pyutils/files/lockfile.py b/src/pyutils/files/lockfile.py index 44896c5..96bc40a 100644 --- a/src/pyutils/files/lockfile.py +++ b/src/pyutils/files/lockfile.py @@ -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 -- 2.46.0