~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/model/buildqueue.py

  • Committer: Raphael Badin
  • Date: 2012-01-04 16:39:15 UTC
  • mto: This revision was merged to the branch mainline in revision 14654.
  • Revision ID: raphael.badin@canonical.com-20120104163915-googt0xvdw4fy9zm
Precache more data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
# pylint: disable-msg=E0611,W0212
53
53
    )
54
54
from lp.services.job.interfaces.job import JobStatus
55
55
from lp.services.job.model.job import Job
 
56
from lp.services.propertycache import (
 
57
    cachedproperty,
 
58
    get_property_cache,
 
59
    )
56
60
from lp.services.webapp.interfaces import (
57
61
    DEFAULT_FLAVOR,
58
62
    IStoreSelector,
138
142
        """See `IBuildQueue`."""
139
143
        return IBuildFarmJobBehavior(self.specific_job)
140
144
 
141
 
    @property
 
145
    @cachedproperty
142
146
    def specific_job(self):
143
147
        """See `IBuildQueue`."""
144
148
        specific_class = specific_job_classes()[self.job_type]
145
149
        return specific_class.getByJob(self.job)
146
150
 
 
151
    def _clear_specific_job_cache(self):
 
152
        del get_property_cache(self).specific_job
 
153
 
147
154
    @staticmethod
148
155
    def preloadSpecificJobData(queues):
149
156
        key = attrgetter('job_type')
158
165
            if len(list(specific_jobs)) == 0:
159
166
                continue
160
167
            specific_class.preloadJobsData(specific_jobs)
 
168
            specific_jobs_dict = dict(
 
169
                (specific_job.job, specific_job)
 
170
                    for specific_job in specific_jobs)
 
171
            for queue in queue_subset:
 
172
                cache = get_property_cache(queue)
 
173
                cache.specific_job = specific_jobs_dict[queue.job]
161
174
 
162
175
    @property
163
176
    def date_started(self):
180
193
        SQLBase.destroySelf(self)
181
194
        specific_job.cleanUp()
182
195
        job.destroySelf()
 
196
        self._clear_specific_job_cache()
183
197
 
184
198
    def manualScore(self, value):
185
199
        """See `IBuildQueue`."""