Commit 02fc74da authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

workerpool: Simplify log messages


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent d16e6fd9
......@@ -430,8 +430,7 @@ class _JobQueueWorker(workerpool.BaseWorker):
@param job: the job to be processed
"""
logging.info("Worker %s processing job %s",
self.worker_id, job.id)
logging.info("Processing job %s", job.id)
proc = mcpu.Processor(self.pool.queue.context, job.id)
queue = job.queue
try:
......@@ -527,8 +526,7 @@ class _JobQueueWorker(workerpool.BaseWorker):
finally:
queue.release()
logging.info("Worker %s finished job %s, status = %s",
self.worker_id, job_id, status)
logging.info("Finished job %s, status = %s", job_id, status)
class _JobQueueWorkerPool(workerpool.WorkerPool):
......
......@@ -44,7 +44,6 @@ class BaseWorker(threading.Thread, object):
"""
super(BaseWorker, self).__init__(name=worker_id)
self.pool = pool
self.worker_id = worker_id
self._current_task = None
def ShouldTerminate(self):
......@@ -89,12 +88,12 @@ class BaseWorker(threading.Thread, object):
# We only wait if there's no task for us.
if not pool._tasks:
logging.debug("Worker %s: waiting for tasks", self.worker_id)
logging.debug("Waiting for tasks")
# wait() releases the lock and sleeps until notified
pool._pool_to_worker.wait()
logging.debug("Worker %s: notified while waiting", self.worker_id)
logging.debug("Notified while waiting")
# Were we woken up in order to terminate?
if pool._ShouldWorkerTerminateUnlocked(self):
......@@ -114,14 +113,11 @@ class BaseWorker(threading.Thread, object):
# Run the actual task
try:
logging.debug("Worker %s: starting task %r",
self.worker_id, self._current_task)
logging.debug("Starting task %r", self._current_task)
self.RunTask(*self._current_task)
logging.debug("Worker %s: done with task %r",
self.worker_id, self._current_task)
logging.debug("Done with task %r", self._current_task)
except: # pylint: disable-msg=W0702
logging.error("Worker %s: Caught unhandled exception",
self.worker_id, exc_info=True)
logging.exception("Caught unhandled exception")
finally:
# Notify pool
pool._lock.acquire()
......@@ -132,7 +128,7 @@ class BaseWorker(threading.Thread, object):
finally:
pool._lock.release()
logging.debug("Worker %s: terminates", self.worker_id)
logging.debug("Terminates")
def RunTask(self, *args):
"""Function called to start a task.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment