summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-04-19 02:32:13 +1200
committerRobert Collins <robertc@robertcollins.net>2013-04-19 02:32:13 +1200
commit610acebaff00b30303dc11644e0a88931d760a28 (patch)
tree0ccffda5ec7a3ab26fede8fab13c03caaf8a71da
parent8d5e227ebf36deb8c5aab665b90a46e7630e0032 (diff)
parent56d8757252b22931c1f3821bff04bd0b0c80d746 (diff)
downloadtestrepository-610acebaff00b30303dc11644e0a88931d760a28.tar.gz
* Switch to using multiprocessing to determine CPU counts.
(Chris Jones, #1092276)
-rw-r--r--NEWS3
-rw-r--r--doc/MANUAL.txt8
-rw-r--r--testrepository/testcommand.py14
3 files changed, 13 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index 41fb14f..419c19e 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ NEXT (In development)
CHANGES
-------
+* Switch to using multiprocessing to determine CPU counts.
+ (Chris Jones, #1092276)
+
* The cli UI now has primitive differentiation between multiple stream types.
This is not yet exposed to the end user, but is sufficient to enable the
load command to take interactive input without it reading from the raw
diff --git a/doc/MANUAL.txt b/doc/MANUAL.txt
index 16bbe80..cb76c66 100644
--- a/doc/MANUAL.txt
+++ b/doc/MANUAL.txt
@@ -165,10 +165,10 @@ Python module to store the duration of each test. On some platforms (to date
only OSX) there is no bulk-update API and performance may be impacted if you
have many (10's of thousands) of tests.
-On Linux, testrepository will inspect /proc/cpuinfo to determine how many CPUs
-are present in the machine, and run one worker per CPU. On other operating
-systems, or if you need to control the number of workers that are used, the
---concurrency option will let you do so::
+To determine how many CPUs are present in the machine, testrepository will
+use the multiprocessing Python module (present since 2.6). On operating systems
+where this is not implemented, or if you need to control the number of workers
+that are used, the --concurrency option will let you do so::
$ testr run --parallel --concurrency=2
diff --git a/testrepository/testcommand.py b/testrepository/testcommand.py
index aba797a..ef285ab 100644
--- a/testrepository/testcommand.py
+++ b/testrepository/testcommand.py
@@ -24,6 +24,7 @@ import re
import subprocess
import sys
import tempfile
+import multiprocessing
from textwrap import dedent
from fixtures import Fixture
@@ -404,14 +405,11 @@ class TestListingFixture(Fixture):
return int(out.strip())
def local_concurrency(self):
- if sys.platform == 'linux2':
- concurrency = None
- for line in open('/proc/cpuinfo', 'rt'):
- if line.startswith('processor'):
- concurrency = int(line[line.find(':')+1:]) + 1
- return concurrency
- # No concurrency logic known.
- return None
+ try:
+ return multiprocessing.cpu_count()
+ except NotImplementedError:
+ # No concurrency logic known.
+ return None
class TestCommand(Fixture):