Commit 7064f1da authored by Julian Andres Klode's avatar Julian Andres Klode

Convert apt.Cache.commit and apt_pkg.DepCache.commit to FE lock

This should fix most problems with locking.
parent bb995b19
Pipeline #16042 failed with stages
in 2 minutes and 23 seconds
......@@ -576,22 +576,15 @@ class Cache(object):
except AttributeError:
install_progress.start_update()
# Need to unlock really hard, since the lock is reference
# counted and we must make sure that we are _really_ unlocked.
lock_count = 0
while True:
try:
apt_pkg.pkgsystem_unlock()
except apt_pkg.Error:
break
lock_count += 1
did_unlock = apt_pkg.pkgsystem_is_locked()
if did_unlock:
apt_pkg.pkgsystem_unlock_inner()
try:
res = install_progress.run(pm)
finally:
# Reinstate lock count
for i in range(lock_count):
apt_pkg.pkgsystem_lock()
if did_unlock:
apt_pkg.pkgsystem_lock_inner()
try:
install_progress.finishUpdate() # type: ignore
......
......@@ -16,6 +16,9 @@ Changed
for that version rather than the highest priority for one of its
package files.
* :meth:`apt.Cache.commit` and :meth:`apt_pkg.DepCache.commit` now use
frontend locking to run dpkg.
Added
------
* The class :class:`apt_pkg.PackageRecords` can now lookup custom fields
......
......@@ -169,7 +169,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args)
//FIXME: make this more flexible, e.g. with a failedDl handler
if(Failed)
Py_RETURN_FALSE;
_system->UnLock(true);
_system->UnLockInner(true);
pkgPackageManager::OrderResult Res = iprogress.Run(PM);
//std::cout << "iprogress.Run() returned: " << (int)Res << std::endl;
......@@ -189,7 +189,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args)
if (PM->GetArchives(&Fetcher,&List,&Recs) == false) {
Py_RETURN_FALSE;
}
_system->Lock();
_system->LockInner();
}
return HandleErrors(Py_None);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment