Merge lp:~jml/pkgme-devportal/delete-lp-cache into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 40
Merged at revision: 39
Proposed branch: lp:~jml/pkgme-devportal/delete-lp-cache
Merge into: lp:pkgme-devportal
Diff against target: 57 lines (+19/-3)
2 files modified
devportalbinary/database.py (+18/-3)
setup.py (+1/-0)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/delete-lp-cache
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+98823@code.launchpad.net

Commit message

Delete launchpadlib cache after fetching symbols.

Description of the change

I ran the package importer overnight using pkgme-binary to import binary packages. I hit the disk usage limit, as for every package it would create a temporary directory for the launchpadlib cache to avoid dependency issues, but it would never delete that directory. Each of the directories was 1.5MB, so this quickly hit the ~7G disk size.

This patch turns our launchpadlib acquisition helper into a Fixture, and makes fixtures a direct dependency of pkgme-binary.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Good catch, thanks.

Thanks for taking on the lplib bug as well.

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/database.py'
2--- devportalbinary/database.py 2012-02-01 17:59:23 +0000
3+++ devportalbinary/database.py 2012-03-22 11:56:18 +0000
4@@ -29,6 +29,10 @@
5 ConfigSection as Section,
6 StringConfigOption as StringOption,
7 )
8+from fixtures import (
9+ Fixture,
10+ TempDir,
11+ )
12
13 from launchpadlib import (
14 uris,
15@@ -52,8 +56,18 @@
16 ARCHITECTURES = ('i386', 'all')
17
18
19-def get_lp():
20- return Launchpad.login_anonymously(APPLICATION_NAME, SERVICE_ROOT, tempfile.mkdtemp())
21+class LaunchpadFixture(Fixture):
22+
23+ def __init__(self, application_name, service_root):
24+ super(LaunchpadFixture, self).__init__()
25+ self._app_name = application_name
26+ self._service_root = service_root
27+
28+ def setUp(self):
29+ super(LaunchpadFixture, self).setUp()
30+ tempdir = self.useFixture(TempDir())
31+ self.anonymous = Launchpad.login_anonymously(
32+ self._app_name, self._service_root, tempdir.path)
33
34
35 def iter_published_sources(lp, since=None, name=None, exact_match=False):
36@@ -444,7 +458,8 @@
37 finder = BinaryPackage.find
38 else:
39 finder = SourcePackage.find
40- package = finder(get_lp(), package_name)
41+ with LaunchpadFixture(APPLICATION_NAME, SERVICE_ROOT) as lp:
42+ package = finder(lp.anonymous, package_name)
43 if not package:
44 return
45 symbols = [
46
47=== modified file 'setup.py'
48--- setup.py 2011-12-05 20:34:11 +0000
49+++ setup.py 2012-03-22 11:56:18 +0000
50@@ -30,6 +30,7 @@
51 'configglue',
52 'launchpadlib',
53 'pkgme',
54+ 'fixtures',
55 'storm',
56 ],
57 entry_points = {

Subscribers

People subscribed via source and target branches