diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py index c8b7f0c039..2562c7fad9 100644 --- a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py @@ -11,7 +11,6 @@ import json from typing import Iterable, AnyStr, Any, Callable import traceback -import multiprocessing from collections import namedtuple from ruamel.yaml import ( @@ -28,21 +27,19 @@ from eth2spec.test.exceptions import SkippedTest from .gen_typing import TestProvider +from .settings import ( + GENERATOR_MODE, + MODE_MULTIPROCESSING, + MODE_SINGLE_PROCESS, + NUM_PROCESS, + TIME_THRESHOLD_TO_PRINT, +) # Flag that the runner does NOT run test via pytest context.is_pytest = False -TIME_THRESHOLD_TO_PRINT = 1.0 # seconds - -# Generator mode setting -MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS' -MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING' - -GENERATOR_MODE = MODE_MULTIPROCESSING - - @dataclass class Diagnostics(object): collected_test_count: int = 0 @@ -243,8 +240,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]): all_test_case_params.append(item) if GENERATOR_MODE == MODE_MULTIPROCESSING: - num_process = multiprocessing.cpu_count() // 2 - 1 - with Pool(processes=num_process) as pool: + with Pool(processes=NUM_PROCESS) as pool: results = pool.map(worker_function, iter(all_test_case_params)) for result in results: diff --git a/tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py new file mode 100644 index 0000000000..b8c3e591fb --- /dev/null +++ b/tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py @@ -0,0 +1,13 @@ +import multiprocessing + + +# Generator mode setting +MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS' +MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING' +# Test generator mode +GENERATOR_MODE = MODE_MULTIPROCESSING +# Number of subprocesses when using MODE_MULTIPROCESSING +NUM_PROCESS = multiprocessing.cpu_count() // 2 - 1 + +# Diagnostics +TIME_THRESHOLD_TO_PRINT = 1.0 # seconds