Commit 0aeeb6e3 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

jqueue: Update worker thread name to include opcode summary

With this patch, the worker thread name is updated to include a short
summary of the opcode (basically its OP_ID). The base name of job queue
threads is shortened from “JobQueue” to “Jq”. Logs and the lock monitor
will show a job verifying the cluster as e.g. “Jq2/Job1742/C_VERIFY”.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent ff8ab07e
......@@ -1137,21 +1137,56 @@ class _JobQueueWorker(workerpool.BaseWorker):
queue = job.queue
assert queue == self.pool.queue
self.SetTaskName("Job%s" %
setname_fn = lambda op: self.SetTaskName(self._GetWorkerName(job, op))
proc = mcpu.Processor(queue.context,
if not _JobProcessor(queue, proc.ExecOpCode, job)():
# Create wrapper for setting thread name
wrap_execop_fn = compat.partial(self._WrapExecOpCode, setname_fn,
if not _JobProcessor(queue, wrap_execop_fn, job)():
# Schedule again
raise workerpool.DeferTask(priority=job.CalcPriority())
def _WrapExecOpCode(setname_fn, execop_fn, op, *args, **kwargs):
"""Updates the worker thread name to include a short summary of the opcode.
@param setname_fn: Callable setting worker thread name
@param execop_fn: Callable for executing opcode (usually
return execop_fn(op, *args, **kwargs)
def _GetWorkerName(job, op):
"""Sets the worker thread name.
@type job: L{_QueuedJob}
@type op: L{opcodes.OpCode}
parts = ["Job%s" %]
if op:
return "/".join(parts)
class _JobQueueWorkerPool(workerpool.WorkerPool):
"""Simple class implementing a job-processing workerpool.
def __init__(self, queue):
super(_JobQueueWorkerPool, self).__init__("JobQueue",
super(_JobQueueWorkerPool, self).__init__("Jq",
self.queue = queue
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