diff options
author | Robert Collins <robertc@robertcollins.net> | 2013-04-19 02:32:13 +1200 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2013-04-19 02:32:13 +1200 |
commit | 610acebaff00b30303dc11644e0a88931d760a28 (patch) | |
tree | 0ccffda5ec7a3ab26fede8fab13c03caaf8a71da | |
parent | 8d5e227ebf36deb8c5aab665b90a46e7630e0032 (diff) | |
parent | 56d8757252b22931c1f3821bff04bd0b0c80d746 (diff) | |
download | testrepository-610acebaff00b30303dc11644e0a88931d760a28.tar.gz |
* Switch to using multiprocessing to determine CPU counts.
(Chris Jones, #1092276)
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | doc/MANUAL.txt | 8 | ||||
-rw-r--r-- | testrepository/testcommand.py | 14 |
3 files changed, 13 insertions, 12 deletions
@@ -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): |