Skip to content

Commit

Permalink
vmupdate: fix waiting for the other apt-get process
Browse files Browse the repository at this point in the history
apt-get uses fcntl F_SETLK for locking, not flock(). Update the function
accordingly.

Fixes: 8fa2929 "vmupdate: wait for other apt-get to complete"
  • Loading branch information
marmarek committed Dec 21, 2024
1 parent 4121dee commit 095b382
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vmupdate/agent/source/apt/apt_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def wait_for_lock(self):
"""
Wait for any other apt-get instance to finish.
"""
with open("/var/lib/apt/lists/lock") as f_lock:
fcntl.flock(f_lock.fileno(), fcntl.LOCK_EX)
with open("/var/lib/apt/lists/lock", "rb+") as f_lock:
fcntl.lockf(f_lock.fileno(), fcntl.LOCK_EX)

def refresh(self, hard_fail: bool) -> ProcessResult:
"""
Expand Down

0 comments on commit 095b382

Please sign in to comment.