Debian Codegraph @

tests/f/database/04-lock-recover/bin/cylc-db-lock

raw
1 #!/usr/bin/env python3
2 """Lock a workflow's database file."""
3
4 from fcntl import lockf, LOCK_SH
5 import os
6 from subprocess import call
7
8 def main():
9 handle = open(
10 os.path.join(os.getenv("CYLC_WORKFLOW_RUN_DIR"), "log", "db"))
11 lockf(handle, LOCK_SH)
12 call([
13 "cylc", "task-message", "I have locked the public database file"])
14 workflow_log_dir = os.getenv("CYLC_WORKFLOW_LOG_DIR")
15 while True:
16 for line in open(os.path.join(workflow_log_dir, "log")):
17 if "write attempt (1) did not complete" in line:
18 return
19
20 if __name__ == "__main__":
21 main()