Functions: Add override_threads

Signed-off-by: Luigi311 <git@luigi311.com>
This commit is contained in:
Luigi311
2024-01-10 02:12:57 -07:00
parent 28c166146e
commit 873735900f

View File

@@ -93,11 +93,18 @@ def search_mapping(dictionary: dict, key_value: str):
return None return None
def future_thread_executor(args: list, threads: int = 32): def future_thread_executor(
args: list, threads: int = None, override_threads: bool = False
):
futures_list = [] futures_list = []
results = [] results = []
workers = min(int(os.getenv("MAX_THREADS", 32)), os.cpu_count() * 2, threads) workers = min(int(os.getenv("MAX_THREADS", 32)), os.cpu_count() * 2)
if threads:
workers = min(threads, workers)
if override_threads:
workers = threads
# If only one worker, run in main thread to avoid overhead # If only one worker, run in main thread to avoid overhead
if workers == 1: if workers == 1: