Commit 99fb250b authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

jqueue: Set task ID for jobs added to workerpool



The job ID is re-used as the task ID, as job IDs are unique.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent bba69414
......@@ -35,6 +35,7 @@ import time
import weakref
import threading
import itertools
import operator
try:
# pylint: disable=E0611
......@@ -69,6 +70,9 @@ JOBQUEUE_THREADS = 25
_LOCK = "_lock"
_QUEUE = "_queue"
#: Retrieves "id" attribute
_GetIdAttr = operator.attrgetter("id")
class CancelJob(Exception):
"""Special exception to cancel a job.
......@@ -2257,7 +2261,8 @@ class JobQueue(object):
"""
assert self._lock.is_owned(shared=0), "Must own lock in exclusive mode"
self._wpool.AddManyTasks([(job, ) for job in jobs],
priority=[job.CalcPriority() for job in jobs])
priority=[job.CalcPriority() for job in jobs],
task_id=map(_GetIdAttr, jobs))
def _GetJobStatusForDependencies(self, job_id):
"""Gets the status of a job for dependencies.
......
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