Add parallel threading

This commit is contained in:
Luigi311
2022-06-14 22:36:44 -06:00
parent beb4e667ae
commit 0584a85f90
5 changed files with 233 additions and 170 deletions

View File

@@ -1,10 +1,12 @@
import os
from concurrent.futures import ThreadPoolExecutor
from dotenv import load_dotenv
load_dotenv(override=True)
logfile = os.getenv("LOGFILE","log.log")
def logger(message, log_type=0):
def logger(message: str, log_type=0):
debug = str_to_bool(os.getenv("DEBUG", "True"))
debug_level = os.getenv("DEBUG_LEVEL", "info").lower()
@@ -114,3 +116,20 @@ def generate_library_guids_dict(user_list: dict, generate_output: int):
return show_output_dict, episode_output_dict, movies_output_dict
def future_thread_executor(args: list):
futures_list = []
results = []
with ThreadPoolExecutor() as executor:
for arg in args:
# * arg unpacks the list into actual arguments
futures_list.append(executor.submit(*arg))
for future in futures_list:
try:
result = future.result()
results.append(result)
except Exception as e:
raise Exception(e)
return results