From 5bdce580cb9c6a79dd1cf1f9cac6593ae90a337e Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 31 Jul 2008 14:33:36 +0000 Subject: [PATCH] jqueue: Store context in job queue instead of worker pool The job queue will need to access to configuration, which is provided through the context object, to get a list of nodes. Reviewed-by: iustinp --- lib/jqueue.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jqueue.py b/lib/jqueue.py index c78b255ea..6297bdf33 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -181,7 +181,7 @@ class _JobQueueWorker(workerpool.BaseWorker): """ logging.debug("Worker %s processing job %s", self.worker_id, job.id) - proc = mcpu.Processor(self.pool.context) + proc = mcpu.Processor(self.pool.queue.context) queue = job.queue try: try: @@ -242,16 +242,17 @@ class _JobQueueWorker(workerpool.BaseWorker): class _JobQueueWorkerPool(workerpool.WorkerPool): - def __init__(self, context): + def __init__(self, queue): super(_JobQueueWorkerPool, self).__init__(JOBQUEUE_THREADS, _JobQueueWorker) - self.context = context + self.queue = queue class JobQueue(object): _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) def __init__(self, context): + self.context = context self._memcache = {} self._my_hostname = utils.HostInfo().name @@ -306,7 +307,7 @@ class JobQueue(object): " file") # Setup worker pool - self._wpool = _JobQueueWorkerPool(context) + self._wpool = _JobQueueWorkerPool(self) # We need to lock here because WorkerPool.AddTask() may start a job while # we're still doing our work. -- GitLab