Merge lp:~jconti/oneconf/closeable-cache into lp:oneconf

Proposed by Jason Conti
Status: Merged
Merged at revision: 272
Proposed branch: lp:~jconti/oneconf/closeable-cache
Merge into: lp:oneconf
Diff against target: 21 lines (+5/-4)
1 file modified
oneconf/distributor/Ubuntu.py (+5/-4)
To merge this branch: bzr merge lp:~jconti/oneconf/closeable-cache
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+182502@code.launchpad.net

Description of the change

Close the apt cache once we are finished using it, so we do not leak file descriptors.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'oneconf/distributor/Ubuntu.py'
2--- oneconf/distributor/Ubuntu.py 2011-10-19 16:20:18 +0000
3+++ oneconf/distributor/Ubuntu.py 2013-08-27 21:05:06 +0000
4@@ -35,13 +35,14 @@
5 '''
6
7 LOG.debug ('Compute package list for current host')
8- apt_cache = apt.Cache()
9
10 # get list of all apps installed
11 installed_packages = {}
12- for pkg in apt_cache:
13- if pkg.is_installed:
14- installed_packages[pkg.name] = {"auto": pkg.is_auto_installed}
15+
16+ with apt.Cache() as apt_cache:
17+ for pkg in apt_cache:
18+ if pkg.is_installed:
19+ installed_packages[pkg.name] = {"auto": pkg.is_auto_installed}
20
21 return installed_packages
22

Subscribers

People subscribed via source and target branches