Chromium Code Reviews| Index: gclient_utils.py |
| diff --git a/gclient_utils.py b/gclient_utils.py |
| index 9d1b9dfdd19b981172f19df83e360d12d935dfe6..7b655b8e47c154be8fdbe7ff9ef414c782bab34e 100644 |
| --- a/gclient_utils.py |
| +++ b/gclient_utils.py |
| @@ -784,6 +784,7 @@ class WorkItem(object): |
| self._name = name |
| self.outbuf = cStringIO.StringIO() |
| self.start = self.finish = None |
| + self.resources = [] # List of resources this work item requires. |
| def run(self, work_queue): |
| """work_queue is passed as keyword argument so it should be |
| @@ -869,6 +870,15 @@ class ExecutionQueue(object): |
| ----------------------------------------""" % ( |
| task.name, comment, elapsed, task.outbuf.getvalue().strip()) |
| + def _is_conflict(self, job): |
| + """Checks to see if a job will conflict with another running job.""" |
| + for running_job in self.running: |
| + for used_resource in running_job.item.resources: |
| + print 'Checking resource %s' % used_resource |
|
Sergey Berezin
2016/06/08 01:28:36
Is this a debugging print, or do you intend to kee
hinoka
2016/06/08 18:38:46
Yeah that was a debugging print... I'll keep it as
|
| + if used_resource in job.resources: |
| + return True |
| + return False |
| + |
| def flush(self, *args, **kwargs): |
| """Runs all enqueued items until all are executed.""" |
| kwargs['work_queue'] = self |
| @@ -892,9 +902,10 @@ class ExecutionQueue(object): |
| # Verify its requirements. |
| if (self.ignore_requirements or |
| not (set(self.queued[i].requirements) - set(self.ran))): |
| - # Start one work item: all its requirements are satisfied. |
| - self._run_one_task(self.queued.pop(i), args, kwargs) |
| - break |
| + if not self._is_conflict(self.queued[i]): |
| + # Start one work item: all its requirements are satisfied. |
| + self._run_one_task(self.queued.pop(i), args, kwargs) |
| + break |
| else: |
| # Couldn't find an item that could run. Break out the outher loop. |
| break |