Compare commits

...

2 Commits

Author SHA1 Message Date
Ronny Pfannschmidt
771f248a04 refactor cpu number autodetection to avoid the regression 2015-08-19 21:34:26 +02:00
Ronny Pfannschmidt
c0c794b961 Added tag v1.13 for changeset 4e25f4c568be 2015-08-18 08:45:54 +02:00
3 changed files with 18 additions and 10 deletions

View File

@@ -17,3 +17,4 @@ cd44a941c833c098e4899fe3d42a96703754d0d5 1.5
4406fc2a6427fadc021ed7e43e7aa5032b1ea91f 1.10 4406fc2a6427fadc021ed7e43e7aa5032b1ea91f 1.10
220f6e46eb71a6212ccbe6b67b9e6edcf8ee4fa5 1.11 220f6e46eb71a6212ccbe6b67b9e6edcf8ee4fa5 1.11
39ef85dbc893cc63dede11601208098a667b58e9 1.12 39ef85dbc893cc63dede11601208098a667b58e9 1.12
4e25f4c568be2d7cb4d1739638a9e66bbf28f588 v1.13

View File

@@ -1,3 +1,9 @@
1.13.1
-------
- fix a regression -n 0 now disables xdist again
1.13 1.13
------------------------- -------------------------
@@ -16,7 +22,7 @@
- new "--max-slave-restart" option that can be used to control maximum - new "--max-slave-restart" option that can be used to control maximum
number of times pytest-xdist can restart slaves due to crashes. Thanks to number of times pytest-xdist can restart slaves due to crashes. Thanks to
Anatoly Bubenkov for the report and Bruno Oliveira for the PR. Anatoly Bubenkov for the report and Bruno Oliveira for the PR.
- release as wheel - release as wheel
- "-n" option now can be set to "auto" for automatic detection of number - "-n" option now can be set to "auto" for automatic detection of number

View File

@@ -1,12 +1,20 @@
import multiprocessing
import py import py
import pytest import pytest
def parse_numprocesses(s):
if s == 'auto':
import multiprocessing
return multiprocessing.cpu_count()
else:
return int(s)
def pytest_addoption(parser): def pytest_addoption(parser):
group = parser.getgroup("xdist", "distributed and subprocess testing") group = parser.getgroup("xdist", "distributed and subprocess testing")
group._addoption('-n', dest="numprocesses", metavar="numprocesses", group._addoption('-n', dest="numprocesses", metavar="numprocesses",
action="store", action="store",
type=parse_numprocesses,
help="shortcut for '--dist=load --tx=NUM*popen', " help="shortcut for '--dist=load --tx=NUM*popen', "
"you can use 'auto' here for auto detection CPUs number on " "you can use 'auto' here for auto detection CPUs number on "
"host system") "host system")
@@ -68,13 +76,6 @@ def pytest_configure(config):
@pytest.mark.tryfirst @pytest.mark.tryfirst
def pytest_cmdline_main(config): def pytest_cmdline_main(config):
if config.option.numprocesses: if config.option.numprocesses:
if config.option.numprocesses == 'auto':
config.option.numprocesses = multiprocessing.cpu_count()
else:
try:
config.option.numprocesses = int(config.option.numprocesses)
except ValueError:
config.option.numprocesses = 1
config.option.dist = "load" config.option.dist = "load"
config.option.tx = ['popen'] * config.option.numprocesses config.option.tx = ['popen'] * config.option.numprocesses
if config.option.distload: if config.option.distload: