diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2018-01-22 19:23:20 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2018-01-26 10:56:40 +0000 |
commit | a49eb85771df2d5e9ac1d86001e163651ca251f8 (patch) | |
tree | 873451b6faffb0f279fb9a464bded5c32ba6265d /packaging-tools/threadedwork.py | |
parent | 127bc5ff91b0a1bf3879a5e1df4d03fb3bb38014 (diff) |
we only need threads for tasks
This avoids to create unused threads for low task count.
Change-Id: I0f25f7ea4e65edd22c026732b2bc4ad9d9dfba7f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'packaging-tools/threadedwork.py')
-rw-r--r-- | packaging-tools/threadedwork.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/packaging-tools/threadedwork.py b/packaging-tools/threadedwork.py index 7ed56da6c..fd52a82db 100644 --- a/packaging-tools/threadedwork.py +++ b/packaging-tools/threadedwork.py @@ -187,7 +187,9 @@ class ThreadedWork(): self.queue.put(task) self.taskNumber = self.taskNumber + 1 - def run(self, maxThreads = multiprocessing.cpu_count()): + def run(self, maxThreads=None): + if not maxThreads: + maxThreads = min(multiprocessing.cpu_count(), self.taskNumber) print(self.description) print(os.linesep.join(self.legend)) |