summaryrefslogtreecommitdiff
path: root/regtest
diff options
context:
space:
mode:
authorAdam Reichold <adam.reichold@t-online.de>2016-01-02 09:48:03 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2016-01-02 10:37:02 +0100
commitea75de614e666d8235c38048585315e0d7ff5522 (patch)
treed6ef0a6949aa61512c3775de64804688b5cd7006 /regtest
parent25bb59a81de8a1b6dd23fec871a97ccb11fe9d64 (diff)
regtest: Limit the number of worker threads to the number of documents to create references
The same way we do for the run-tests command.
Diffstat (limited to 'regtest')
-rw-r--r--regtest/TestReferences.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/regtest/TestReferences.py b/regtest/TestReferences.py
index 4eeb330c..e70896fe 100644
--- a/regtest/TestReferences.py
+++ b/regtest/TestReferences.py
@@ -100,19 +100,28 @@ class TestReferences:
backends = self._get_backends()
self._total_tests = total_docs * len(backends)
+ if total_docs == 1:
+ n_workers = 0
+ else:
+ n_workers = min(self.config.threads, total_docs)
+
self.printer.printout_ln('Found %d documents' % (total_docs))
self.printer.printout_ln('Backends: %s' % ', '.join([backend.get_name() for backend in backends]))
- self.printer.printout_ln('Process %d using %d worker threads' % (os.getpid(), self.config.threads))
+ self.printer.printout_ln('Process %d using %d worker threads' % (os.getpid(), n_workers))
self.printer.printout_ln()
- self.printer.printout('Spawning %d workers...' % (self.config.threads))
+ if n_workers > 0:
+ self.printer.printout('Spawning %d workers...' % (n_workers))
- for n_thread in range(self.config.threads):
- thread = Thread(target=self._worker_thread)
- thread.daemon = True
- thread.start()
+ for n_thread in range(n_workers):
+ thread = Thread(target=self._worker_thread)
+ thread.daemon = True
+ thread.start()
- for doc in docs:
- self._queue.put(doc)
+ for doc in docs:
+ self._queue.put(doc)
- self._queue.join()
+ self._queue.join()
+ else:
+ for doc in docs:
+ self.create_refs_for_file(doc)