summaryrefslogtreecommitdiff
path: root/lockfile.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-07-29 09:11:05 -0700
committerScott Gasch <[email protected]>2021-07-29 09:11:05 -0700
commita08ca309cb5bd7971210a9247a38c9bbe376a6e6 (patch)
tree879e0ee5403d5ede0658db5ed6e4705c86208f9c /lockfile.py
parent4faa994d32223c8d560d9dad0ca90a3f7eb10d6a (diff)
Lockfile custom command, fixup minor things.
Diffstat (limited to 'lockfile.py')
-rw-r--r--lockfile.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lockfile.py b/lockfile.py
index ee8c255..770beaa 100644
--- a/lockfile.py
+++ b/lockfile.py
@@ -37,9 +37,11 @@ class LockFile(object):
*,
do_signal_cleanup: bool = True,
expiration_timestamp: Optional[float] = None,
+ override_command: Optional[str] = None,
) -> None:
self.is_locked = False
self.lockfile = lockfile_path
+ self.override_command = override_command
if do_signal_cleanup:
signal.signal(signal.SIGINT, self._signal)
signal.signal(signal.SIGTERM, self._signal)
@@ -117,10 +119,14 @@ class LockFile(object):
self.release()
def _get_lockfile_contents(self) -> str:
+ if self.override_command:
+ cmd = self.override_command
+ else:
+ cmd = ' '.join(sys.argv)
contents = LockFileContents(
pid = os.getpid(),
- commandline = ' '.join(sys.argv),
- expiration_timestamp = self.expiration_timestamp
+ cmd,
+ expiration_timestamp = self.expiration_timestamp,
)
return json.dumps(contents.__dict__)