diff options
| -rw-r--r-- | apt/cache.py | 42 | ||||
| -rw-r--r-- | debian/changelog | 8 |
2 files changed, 30 insertions, 20 deletions
diff --git a/apt/cache.py b/apt/cache.py index 9218263b..01034cf9 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -140,31 +140,35 @@ class Cache(object): if lock < 0: raise IOError, "Failed to lock %s" % lockfile - # this may as well throw a SystemError exception - if not pm.GetArchives(fetcher, self._list, self._records): - return False - # now run the fetcher, throw exception if something fails to be - # fetched - res = self._runFetcher(fetcher) - # cleanup - os.close(lock) - return res + try: + # this may as well throw a SystemError exception + if not pm.GetArchives(fetcher, self._list, self._records): + return False + # now run the fetcher, throw exception if something fails to be + # fetched + return self._runFetcher(fetcher) + finally: + os.close(lock) def update(self, fetchProgress=None): lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" lock = apt_pkg.GetLock(lockfile) if lock < 0: raise IOError, "Failed to lock %s" % lockfile - if fetchProgress == None: - fetchProgress = apt.progress.FetchProgress() - fetcher = apt_pkg.GetAcquire(fetchProgress) - # this can throw a exception - self._list.GetIndexes(fetcher) - # now run the fetcher, throw exception if something fails to be - # fetched - if self._runFetcher(fetcher) == fetcher.ResultContinue: - return True - return False + + try: + if fetchProgress == None: + fetchProgress = apt.progress.FetchProgress() + fetcher = apt_pkg.GetAcquire(fetchProgress) + # this can throw a exception + self._list.GetIndexes(fetcher) + # now run the fetcher, throw exception if something fails to be + # fetched + if self._runFetcher(fetcher) == fetcher.ResultContinue: + return True + return False + finally: + os.close(lock) def installArchives(self, pm, installProgress): installProgress.startUpdate() diff --git a/debian/changelog b/debian/changelog index 75604746..7dbc7c91 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.16.2ubuntu4) dapper; urgency=low + + * apt/cache.py: Release locks on failure (thanks to Colin Watson) + (closes: #35867) + + -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 21 Mar 2006 15:09:14 +0100 + python-apt (0.6.16.2ubuntu3) dapper; urgency=low * apt/package.py: undo some damager from pychecker @@ -24,7 +31,6 @@ python-apt (0.6.16.2ubuntu1) dapper; urgency=low - fix various pychecker warnings * apt/cache.py, apt/package.py: fix various pychecker warnings - -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 28 Feb 2006 12:04:37 +0100 python-apt (0.6.16.1) unstable; urgency=low |
