Merge lp:~cjwatson/launchpad/dpkg-architecture-subprocess-timeline into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18328
Proposed branch: lp:~cjwatson/launchpad/dpkg-architecture-subprocess-timeline
Merge into: lp:launchpad
Diff against target: 38 lines (+13/-2)
1 file modified
lib/lp/soyuz/adapters/buildarch.py (+13/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/dpkg-architecture-subprocess-timeline
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+317381@code.launchpad.net

Commit message

Add timeline information to dpkg-architecture subprocess call, to help debug #1062638.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Worth including DEB_HOST_ARCH too? Though it really shouldn't matter...

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/adapters/buildarch.py'
2--- lib/lp/soyuz/adapters/buildarch.py 2015-12-31 00:01:07 +0000
3+++ lib/lp/soyuz/adapters/buildarch.py 2017-02-18 01:49:55 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 __metaclass__ = type
10@@ -11,6 +11,10 @@
11 import os
12 import subprocess
13
14+from lazr.restful.utils import get_current_browser_request
15+
16+from lp.services.timeline.requesttimeline import get_request_timeline
17+
18
19 class DpkgArchitectureCache:
20 """Cache the results of asking questions of dpkg-architecture."""
21@@ -20,10 +24,17 @@
22
23 def match(self, arch, wildcard):
24 if (arch, wildcard) not in self._matches:
25+ timeline = get_request_timeline(get_current_browser_request())
26 command = ["dpkg-architecture", "-i%s" % wildcard]
27 env = dict(os.environ)
28 env["DEB_HOST_ARCH"] = arch
29- ret = (subprocess.call(command, env=env) == 0)
30+ action = timeline.start(
31+ "dpkg-architecture", "-i%s" % wildcard,
32+ "DEB_HOST_ARCH=%s" % arch)
33+ try:
34+ ret = (subprocess.call(command, env=env) == 0)
35+ finally:
36+ action.finish()
37 self._matches[(arch, wildcard)] = ret
38 return self._matches[(arch, wildcard)]
39