diff options
| author | Steven Knight <knight@baldmt.com> | 2003-10-09 22:20:17 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2003-10-09 22:20:17 (GMT) |
| commit | 34f47299ed9fa4eb468201ae6e5cb4e0523a3dc2 (patch) | |
| tree | 242ccda5c6f457941574d3e2b735a5bdec23d702 /src/engine/SCons/Job.py | |
| parent | c758e5b84c91197de129134c2ab67f45f96dff52 (diff) | |
| download | SCons-34f47299ed9fa4eb468201ae6e5cb4e0523a3dc2.zip SCons-34f47299ed9fa4eb468201ae6e5cb4e0523a3dc2.tar.gz SCons-34f47299ed9fa4eb468201ae6e5cb4e0523a3dc2.tar.bz2 | |
Fix a problem with the new Parallel job support when a command fails. (J.T. Conklin)
Diffstat (limited to 'src/engine/SCons/Job.py')
| -rw-r--r-- | src/engine/SCons/Job.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py index 202f86f..0c01b85 100644 --- a/src/engine/SCons/Job.py +++ b/src/engine/SCons/Job.py @@ -147,12 +147,7 @@ class ThreadPool: def __init__(self, num): """Create the request and reply queues, and 'num' worker threads.""" - # Ideally we wouldn't have to artificially limit the number of - # tasks that can be posted to the request queue. But this can - # result in a large number of pending tasks, which at the time - # of this writing causes the taskmaster's next_task method to - # take a very long time. - self.requestQueue = Queue.Queue(num) + self.requestQueue = Queue.Queue() self.resultsQueue = Queue.Queue() # Create worker threads @@ -200,6 +195,9 @@ class Parallel: self.taskmaster = taskmaster self.tp = ThreadPool(num) + self.jobs = 0 + self.maxjobs = num + def start(self): """Start the job. This will begin pulling tasks from the taskmaster and executing them, and return when there are no @@ -207,31 +205,34 @@ class Parallel: an exception), then the job will stop.""" while 1: - task = self.taskmaster.next_task() - if task is None: - break + if self.jobs < self.maxjobs: + task = self.taskmaster.next_task() + if task is None: + break - # prepare task for execution - try: - task.prepare() - except KeyboardInterrupt: - raise - except: - # Let the failed() callback function arrange for the - # build to stop if that's appropriate. - task.failed() + # prepare task for execution + try: + task.prepare() + except KeyboardInterrupt: + raise + except: + # Let the failed() callback function arrange for the + # build to stop if that's appropriate. + task.failed() - # dispatch task - self.tp.put(task) + # dispatch task + self.tp.put(task) + self.jobs = self.jobs + 1 while 1: try: task, ok = self.tp.get_nowait() except Queue.Empty: - if not self.taskmaster.is_blocked(): + if not (self.jobs is self.maxjobs or self.taskmaster.is_blocked()): break task, ok = self.tp.get() + self.jobs = self.jobs - 1 if ok: task.executed() else: |
