[Python-modules-commits] [nose2] 06/08: Add d/p/0003 to fix a documentation issue

Pierre-Elliott Bécue peb-guest at moszumanska.debian.org
Tue Jan 23 21:54:47 UTC 2018


This is an automated email from the git hooks/post-receive script.

peb-guest pushed a commit to branch master
in repository nose2.

commit 87cb4068577bb9c9286e0b6e0ae331205d0249a2
Author: Pierre-Elliott Bécue <becue at crans.org>
Date:   Tue Jan 23 22:15:28 2018 +0100

    Add d/p/0003 to fix a documentation issue
---
 debian/changelog                                   | 12 +++-
 ...s-the-MultiProcess.procs-attribute-access.patch | 67 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 78 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4c67b56..968b519 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,16 @@ nose2 (0.7.3-2) unstable; urgency=medium
     a plugin set before they're loaded. This loading occurs for all calls to
     nose2, including -h option. The fact that the plugin list was in a set did
     introduce some non-deterministic order in the manpage options.
-
- -- Pierre-Elliott Bécue <becue at crans.org>  Tue, 23 Jan 2018 20:13:38 +0100
+  * Add d/p/0003 to fix a documentation issue in docs/plugins/mp.py.
+    The MultiProcess.procs attribute had a default to
+    multiprocessing.cpu_count(). As the defaults are fetched for docs
+    building, this introduces a reproducibility issue and potential others
+    weird things. This patch is to set a default value to 0 in a _procs
+    variable, and then rely on a getter/setter to get/set "procs" at an
+    appropriate value if 0 is kept (ie no configuration or configuration set
+    to 0).
+
+ -- Pierre-Elliott Bécue <becue at crans.org>  Tue, 23 Jan 2018 22:11:09 +0100
 
 nose2 (0.7.3-1) unstable; urgency=medium
 
diff --git a/debian/patches/0003-Tunes-the-MultiProcess.procs-attribute-access.patch b/debian/patches/0003-Tunes-the-MultiProcess.procs-attribute-access.patch
new file mode 100644
index 0000000..acdbe98
--- /dev/null
+++ b/debian/patches/0003-Tunes-the-MultiProcess.procs-attribute-access.patch
@@ -0,0 +1,67 @@
+From: =?utf-8?q?Pierre-Elliott_B=C3=A9cue?= <becue at crans.org>
+Date: Tue, 23 Jan 2018 22:07:21 +0100
+Subject: Tunes the MultiProcess.procs attribute access
+
+ * This attribute had a default to multiprocessing.cpu_count(). As the
+   defaults are fetched for docs building, this introduces a
+   reproducibility issue and potential other weird things. Add a patch
+   to set a default value to 0 in a _procs variable, and then rely on
+   a getter/setter to get/set "procs" at an appropriate value if 0 is
+   kept (ie no configuration or configuration set to 0).
+---
+ docs/plugins/mp.rst |  3 ++-
+ nose2/plugins/mp.py | 23 +++++++++++++++++++++--
+ 2 files changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/docs/plugins/mp.rst b/docs/plugins/mp.rst
+index 945a876..d1dc662 100644
+--- a/docs/plugins/mp.rst
++++ b/docs/plugins/mp.rst
+@@ -41,7 +41,8 @@ config file::
+    If you make the plugin always active by setting ``always-on`` in
+    the ``[multiprocess]`` section of a config file, but do not set
+    ``processes`` or pass :option:`-N`, the number of processes
+-   defaults to the number of CPUs available.
++   defaults to the number of CPUs available. Also note that a value of 0 will
++   set the actual number of processes to the number of CPUs on the computer.
+ 
+ Should one wish to specify the use of internet sockets for 
+ interprocess communications, specify the ``bind_address``
+diff --git a/nose2/plugins/mp.py b/nose2/plugins/mp.py
+index b712bb3..b6317b4 100644
+--- a/nose2/plugins/mp.py
++++ b/nose2/plugins/mp.py
+@@ -21,12 +21,31 @@ class MultiProcess(events.Plugin):
+     def __init__(self):
+         self.addArgument(self.setProcs, 'N', 'processes', '# o procs')
+         self.testRunTimeout = self.config.as_float('test-run-timeout', 60.0)
+-        self.procs = self.config.as_int(
+-            'processes', multiprocessing.cpu_count())
++        self._procs = self.config.as_int(
++            'processes', 0)
+         self.setAddress(self.config.as_str('bind_address', None))
+ 
+         self.cases = {}
+ 
++    @property
++    def procs(self):
++        """Get the appropriate number of procs for self.procs if self._procs is
++        0."""
++
++        if self._procs == 0:
++            try:
++                self._procs = multiprocessing.cpu_count()
++            except NotImplementedError as e:
++                self._procs = 1
++        return self._procs
++
++    @procs.setter
++    def procs(self, value):
++        """Setter for procs property"""
++        if value <= 0:
++            raise AttributeError("Can't set the procs number to less than 1")
++        self._procs = value
++
+     def setProcs(self, num):
+         self.procs = int(num[0])  # FIXME merge n fix
+         self.register()
diff --git a/debian/patches/series b/debian/patches/series
index 6737d5a..f9ba6f2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0001-removes_external_images_from_readme_rst.patch
 0002-Sorts_the_plugin_list_before_loading.patch
+0003-Tunes-the-MultiProcess.procs-attribute-access.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/nose2.git



More information about the Python-modules-commits mailing list