Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Unified Diff: recipe_modules/platform/api.py

Issue 2641253005: Add multiprocessing.cpu_count access to platform module. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_modules/platform/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/platform/api.py
diff --git a/recipe_modules/platform/api.py b/recipe_modules/platform/api.py
index ecd5f673cc345f4165edc7bc51bf8313e44e5bfa..ded9f6ec947ec1395aaeea1a3623a46710303b09 100644
--- a/recipe_modules/platform/api.py
+++ b/recipe_modules/platform/api.py
@@ -4,6 +4,7 @@
import sys
import platform
+import multiprocessing
from recipe_engine import recipe_api
@@ -44,6 +45,7 @@ class PlatformApi(recipe_api.RecipeApi):
# Default to linux/64, unless test case says otherwise.
self._name = norm_plat(self._test_data.get('name', 'linux'))
self._bits = norm_bits(self._test_data.get('bits', 64))
+ self._cpu_count = self._test_data.get('cpu_count', 2)
else: # pragma: no cover
# platform.machine is based on running kernel. It's possible to use 64-bit
# kernel with 32-bit userland, e.g. to give linker slightly more memory.
@@ -60,6 +62,8 @@ class PlatformApi(recipe_api.RecipeApi):
platform.architecture()[0] == '64bit'):
self._bits = 64
+ self._cpu_count = multiprocessing.cpu_count()
+
@property
def is_win(self):
return self.name == 'win'
@@ -86,6 +90,11 @@ class PlatformApi(recipe_api.RecipeApi):
def arch(self):
return self._arch
+ @property
+ def cpu_count(self):
+ """The number of CPU cores, according to multiprocessing.cpu_count()."""
+ return self._cpu_count
+
@staticmethod
def normalize_platform_name(platform):
"""One of python's sys.platform values -> 'win', 'linux' or 'mac'."""
« no previous file with comments | « no previous file | recipe_modules/platform/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698