Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/tests/ftest/container/boundary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
(C) Copyright 2022-2023 Intel Corporation.
(C) Copyright 2025 Hewlett Packard Enterprise Development LP
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent
"""
Expand Down Expand Up @@ -104,9 +104,10 @@ def create_pools(self, num_pools, num_containers):
self.fail('{} pool create threads failed'.format(num_failed))
self.log.info('Created %d pools', num_pools)

# Create all containers for all pools in parallel
# Create all containers for all pools in parallel (specifying max_workers because of the
# 2-second sleep in every thread)
container_manager = ThreadManager(
self.create_container_and_test, self.get_remaining_time() - 30)
self.create_container_and_test, self.get_remaining_time() - 30, max_workers=1024)
all_pool_cont_args = list(itertools.product(self.pool, range(num_containers)))
self.random.shuffle(all_pool_cont_args)
for pool, cont_num in all_pool_cont_args:
Expand Down
8 changes: 6 additions & 2 deletions src/tests/ftest/util/thread_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
(C) Copyright 2021-2023 Intel Corporation.
(C) Copyright 2026 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent
"""
Expand Down Expand Up @@ -77,16 +78,19 @@ class ThreadManager():
# pylint: disable=too-many-ancestors,too-few-public-methods
"""Class to manage running any method as multiple threads."""

def __init__(self, method, timeout=None):
def __init__(self, method, timeout=None, max_workers=None):
"""Initialize a ThreadManager object with the the method to run as a thread.

Args:
method (callable): python method to execute in each thread
timeout (int, optional): timeout for all thread execution. Defaults to None.
max_workers (int, optional): maximum number of threads to run concurrently.
Defaults to None.
"""
self.log = getLogger()
self.method = method
self.timeout = timeout
self.max_workers = max_workers
self.job_kwargs = []
self.futures = {}

Expand All @@ -112,7 +116,7 @@ def run(self):

"""
results = []
with ThreadPoolExecutor() as thread_executor:
with ThreadPoolExecutor(max_workers=self.max_workers) as thread_executor:
self.log.info("Submitting %d threads ...", len(self.job_kwargs))
# Keep track of thread ids by assigning an index to each Future object
futures = {
Expand Down
Loading