Merge ~twom/launchpad:fix-vitals-tests into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Colin Watson
Approved revision: 5502e6dd5e99d3a35e682359876a90eea1ad7233
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:fix-vitals-tests
Merge into: launchpad:master
Diff against target: 17 lines (+6/-0)
1 file modified
lib/lp/buildmaster/manager.py (+6/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+389669@code.launchpad.net

Commit message

testfix: Ensure vitals_map exist

Description of the change

`updateStats` is on a timer, and requires the `vitals_map` attribute of `PrefetchedBuilderFactory` to exist. This is currently only created in the `update` method, so it's possible to race if `updateStats` is called first.
Add an init to `PrefetchedBuilderFactory` and create `vitals_map` in it.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py
2index 3ace0d8..fb9baaa 100644
3--- a/lib/lp/buildmaster/manager.py
4+++ b/lib/lp/buildmaster/manager.py
5@@ -257,6 +257,12 @@ class PrefetchedBuilderFactory(BaseBuilderFactory):
6 from cached data updated by `update`.
7 """
8
9+ def __init__(self, *args, **kwargs):
10+ super(PrefetchedBuilderFactory, self).__init__(*args, **kwargs)
11+ # This needs to exist to avoid race conditions between
12+ # `updateStats` and `update`.
13+ self.vitals_map = {}
14+
15 def update(self):
16 """See `BaseBuilderFactory`."""
17 transaction.abort()

Subscribers

People subscribed via source and target branches

to status/vote changes: