Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix apt cache FD leakage and performance boost lp:1537705 #257
Conversation
|
test coverage decrease... would be nice if someone deep into code could write a simple test for this... if you need test case yaml its in the lp bug https://bugs.launchpad.net/snapcraft/+bug/1537705 |
|
lool pointed out that this patch does not close cache when pkg isnt in cache... we could make this cleaner, but practically we probably always want to bail if someone asks for a build-package that isnt even known to cache, no? |
sergiusens
reviewed
Jan 26, 2016
| try: | ||
| - if not apt.Cache()[pkg].installed: | ||
| + apt_cache = apt.Cache() |
sergiusens
Jan 26, 2016
Collaborator
I wonder if something like this is allowed (apt cache being context aware, I think it is), so mind replacing that with
with apt.Cache() as apt_cache:
if not apt_cache[pkg].installed:
new_package.append(pkg)It might also be more performant to open the apt cache before looping over the packages.
asac
Jan 26, 2016
Contributor
uploaded new rev with comments addressed. fwiw, i tested that it really closes the apt cache this way (before moving it out of the loop)
|
ok, ran static/unit tests locally on latest push and all green... hope good enough :) |
sergiusens
reviewed
Jan 27, 2016
| @@ -58,15 +58,19 @@ | ||
| def install_build_packages(packages): | ||
| + seen = set() | ||
| + seen_add = seen.add | ||
| + unique_packages = [x for x in packages if not (x in seen or seen_add(x))] |
sergiusens
Jan 27, 2016
Collaborator
it seems my comment from before did not stick
Is this a way to get only one item? If so, instead of
seen = set()
seen_add = seen.add
unique_packages = [x for x in packages if not (x in seen or seen_add(x))]do
unique_packages = set(packages)Or bellow in
for pkg in unique_packages:Change that to
for pkg in set(packages):
asac commentedJan 25, 2016
No description provided.