bionic 1.6.3: 1. Verified that the lock is hold during dpkg run added lslocks to aptitude prerm:
$ lxc exec bbb -- strace -o $PWD/log -e openat,open,close,fcntl python3 $PWD/foo.py (Reading database ... 28970 files and directories currently installed.) Removing aptitude (0.8.10-6ubuntu1) ... COMMAND PID TYPE SIZE MODE M START END PATH atd 198 POSIX 4B WRITE 0 0 0 /run/atd.pid python3 2751 POSIX 0B WRITE 0 0 0 /var/lib/dpkg/lock-frontend python3 2751 POSIX 0B WRITE 0 0 0 /var/cache/apt/archives/lock cron 196 FLOCK 4B WRITE 0 0 0 /run/crond.pid dpkg 2761 POSIX 0B WRITE 0 0 0 /var/lib/dpkg/lock Removing aptitude-common (0.8.10-6ubuntu1) ... Processing triggers for man-db (2.8.3-2) ... 2. With system lock helt in my script: #!/usr/bin/python3 import apt, apt_pkg c = apt.Cache() if c["aptitude-common"].is_installed: c["aptitude-common"].mark_delete() else: c["aptitude-common"].mark_install() with apt_pkg.SystemLock(): c.commit() $ lxc exec bbb -- strace -o $PWD/log.locked -e openat,open,close,fcntl python3 $PWD/foo.py (Reading database ... 28970 files and directories currently installed.) Removing aptitude (0.8.10-6ubuntu1) ... COMMAND PID TYPE SIZE MODE M START END PATH atd 198 POSIX 4B WRITE 0 0 0 /run/atd.pid dpkg 3106 POSIX 0B WRITE 0 0 0 /var/lib/dpkg/lock cron 196 FLOCK 4B WRITE 0 0 0 /run/crond.pid python3 3096 POSIX 0B WRITE 0 0 0 /var/lib/dpkg/lock-frontend python3 3096 POSIX 0B WRITE 0 0 0 /var/cache/apt/archives/lock Removing aptitude-common (0.8.10-6ubuntu1) ... Processing triggers for man-db (2.8.3-2) ... Works fine. 3. Investigating strace also shows that the lock-frontend is acquired once, and not released until the end. ** Tags removed: verification-needed-bionic ** Tags added: verification-done-bionic -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1795407 Title: python-apt frontend locking To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/python-apt/+bug/1795407/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs