Skip to content

Commit 1d8ebf9

Browse files
committed
vmupdate: fix waiting for the other apt-get process
apt-get uses fcntl F_SETLK for locking, not flock(). Update the function accordingly. Fixes: 8fa2929 "vmupdate: wait for other apt-get to complete"
1 parent 4121dee commit 1d8ebf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vmupdate/agent/source/apt/apt_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def wait_for_lock(self):
4242
"""
4343
Wait for any other apt-get instance to finish.
4444
"""
45-
with open("/var/lib/apt/lists/lock") as f_lock:
46-
fcntl.flock(f_lock.fileno(), fcntl.LOCK_EX)
45+
with open("/var/lib/apt/lists/lock", "rb+") as f_lock:
46+
fcntl.lockf(f_lock.fileno(), fcntl.LOCK_EX)
4747

4848
def refresh(self, hard_fail: bool) -> ProcessResult:
4949
"""

0 commit comments

Comments
 (0)