commit:     3888e16314afa9107aa0f2d9dce864b85246822c
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 16 06:17:12 2019 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Feb 16 06:17:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3888e163

Replace multiprocessing.cpu_count with portage.util.cpuinfo.get_cpu_count

portage.util.cpuinfo.get_cpu_count was only used in one spot before, and
other call-sites just used multiprocessing.cpu_count() directly.

Replace all multiprocessing.cpu_count() calls with get_cpu_count() in
portage.util.cpuinfo, to ensure consistency in CPU calculation.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 lib/portage/dbapi/porttree.py              |  4 ++--
 lib/portage/util/futures/executor/fork.py  |  4 ++--
 lib/portage/util/futures/iter_completed.py | 18 +++++++++---------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/portage/dbapi/porttree.py b/lib/portage/dbapi/porttree.py
index 2ff3e1b34..64a5f3681 100644
--- a/lib/portage/dbapi/porttree.py
+++ b/lib/portage/dbapi/porttree.py
@@ -1471,11 +1471,11 @@ def _async_manifest_fetchlist(portdb, repo_config, cp, 
cpv_list=None,
        @param cpv_list: list of ebuild cpv values for a Manifest
        @type cpv_list: list
        @param max_jobs: max number of futures to process concurrently (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_jobs: int
        @param max_load: max load allowed when scheduling a new future,
                otherwise schedule no more than 1 future at a time (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_load: int or float
        @param loop: event loop
        @type loop: EventLoop

diff --git a/lib/portage/util/futures/executor/fork.py 
b/lib/portage/util/futures/executor/fork.py
index 72844403c..add7b3c9e 100644
--- a/lib/portage/util/futures/executor/fork.py
+++ b/lib/portage/util/futures/executor/fork.py
@@ -7,13 +7,13 @@ __all__ = (
 
 import collections
 import functools
-import multiprocessing
 import os
 import sys
 import traceback
 
 from portage.util._async.AsyncFunction import AsyncFunction
 from portage.util.futures import asyncio
+from portage.util.cpuinfo import get_cpu_count
 
 
 class ForkExecutor(object):
@@ -24,7 +24,7 @@ class ForkExecutor(object):
        This is entirely driven by an event loop.
        """
        def __init__(self, max_workers=None, loop=None):
-               self._max_workers = max_workers or multiprocessing.cpu_count()
+               self._max_workers = max_workers or get_cpu_count()
                self._loop = asyncio._wrap_loop(loop)
                self._submit_queue = collections.deque()
                self._running_tasks = {}

diff --git a/lib/portage/util/futures/iter_completed.py 
b/lib/portage/util/futures/iter_completed.py
index 31b5e0c78..4c48ea0fe 100644
--- a/lib/portage/util/futures/iter_completed.py
+++ b/lib/portage/util/futures/iter_completed.py
@@ -2,11 +2,11 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import functools
-import multiprocessing
 
 from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
 from portage.util._async.TaskScheduler import TaskScheduler
 from portage.util.futures import asyncio
+from portage.util.cpuinfo import get_cpu_count
 
 
 def iter_completed(futures, max_jobs=None, max_load=None, loop=None):
@@ -18,11 +18,11 @@ def iter_completed(futures, max_jobs=None, max_load=None, 
loop=None):
        @param futures: iterator of asyncio.Future (or compatible)
        @type futures: iterator
        @param max_jobs: max number of futures to process concurrently (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_jobs: int
        @param max_load: max load allowed when scheduling a new future,
                otherwise schedule no more than 1 future at a time (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_load: int or float
        @param loop: event loop
        @type loop: EventLoop
@@ -47,11 +47,11 @@ def async_iter_completed(futures, max_jobs=None, 
max_load=None, loop=None):
        @param futures: iterator of asyncio.Future (or compatible)
        @type futures: iterator
        @param max_jobs: max number of futures to process concurrently (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_jobs: int
        @param max_load: max load allowed when scheduling a new future,
                otherwise schedule no more than 1 future at a time (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_load: int or float
        @param loop: event loop
        @type loop: EventLoop
@@ -61,8 +61,8 @@ def async_iter_completed(futures, max_jobs=None, 
max_load=None, loop=None):
        """
        loop = asyncio._wrap_loop(loop)
 
-       max_jobs = max_jobs or multiprocessing.cpu_count()
-       max_load = max_load or multiprocessing.cpu_count()
+       max_jobs = max_jobs or portage.util.cpuinfo.get_cpu_count()
+       max_load = max_load or portage.util.cpuinfo.get_cpu_count()
 
        future_map = {}
        def task_generator():
@@ -120,11 +120,11 @@ def iter_gather(futures, max_jobs=None, max_load=None, 
loop=None):
        @param futures: iterator of asyncio.Future (or compatible)
        @type futures: iterator
        @param max_jobs: max number of futures to process concurrently (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_jobs: int
        @param max_load: max load allowed when scheduling a new future,
                otherwise schedule no more than 1 future at a time (default
-               is multiprocessing.cpu_count())
+               is portage.util.cpuinfo.get_cpu_count())
        @type max_load: int or float
        @param loop: event loop
        @type loop: EventLoop

Reply via email to