diff options
author | Chris Jones <cmsj@tenshu.net> | 2013-04-16 17:30:53 -0700 |
---|---|---|
committer | Chris Jones <cmsj@tenshu.net> | 2013-04-16 17:30:53 -0700 |
commit | 2bab3fd528f458725fd690fb5abc5b010f1df858 (patch) | |
tree | 4e9d9621743847e18f486371f6fdd954c587fe29 | |
parent | b1170816e23a7525bbc41729096d6121f4ba52f5 (diff) | |
download | testrepository-2bab3fd528f458725fd690fb5abc5b010f1df858.tar.gz |
Switch to multiprocessing for detecting CPU core count. This is present as of Python 2.6
-rw-r--r-- | testrepository/testcommand.py | 14 |
1 files changed, 6 insertions, 8 deletions
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): |