tag 596793 confirmed thanks On Tue, Sep 14, 2010 at 09:49:30AM +0200, Sebastian Heinlein wrote: > Package: python-apt > Version: 0.7.97.1 > Severity: wishlist > > It would be nice to have a lock argument in the apt.cache.Cache.update() > and apt.cache.Cache.commit() methods. > > It would allow to pass the fd (int) of an already acquired lock. The > corresponding methods won't try to get a lock on lists/archives if it's > given. > > The packagekit backend and aptdaemon try to acquire the locks > before executing the tasks to give the user an idea which application > should be closed before the task can be performed, instead of failing > during the task. > > So currently I have to acquire the locks at the start of a > transaction, release it again shortly before call e.g. Cache.update() > and re-aquire them again afterwards until the transaction is done. >
In contrast to you, I prefer a property returning an apt_pkg.FileLock
object, which can then be used like:
with cache.archive_lock:
cache.commit()
cache.update()
# or (possibly with better names)
cache.archive_lock.__enter__()
cache.commit()
cache.update()
cache.archive_lock.__exit__()
Looks a bit more natural, although there is currently no way to get
the fd from the lock (this could be added, though). If called outside
a with block, the functions are the lock themselves (FileLock does
reference-count based locking).
Scheduled for wheezy.
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
pgpmAlV0WyCEO.pgp
Description: PGP signature

