File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 55import logging
66import shutil
77from logfmter import Logfmter
8+ import concurrent .futures
89
910logger = logging .getLogger ("appstream-generator" )
1011
3435# Limits N number of old entries
3536old_limit = int (os .environ .get ("OLD_LIMIT" , 5 ))
3637
38+ # Max concurrent tasks
39+ max_workers = int (os .environ .get ("MAX_WORKERS" , 5 ))
40+
3741
3842def scan_base_dir (base_dir : str ):
3943 for entry in os .scandir (base_dir ):
@@ -273,13 +277,20 @@ def process_repo(path: str):
273277 except Exception as e :
274278 logger .error (f"Error processing repo { repo_name } : { e } " )
275279 return
280+ finally :
281+ return True
276282
277283
278284def main ():
279285 # setup_logging()
280286 # logger.info("test")
287+ thread_pool = concurrent .futures .ThreadPoolExecutor (max_workers = max_workers )
288+ futures = []
281289 for dir in scan_base_dir (base_dir ):
282- process_repo (dir )
290+ futures .append (thread_pool .submit (process_repo , dir ))
291+ _ = concurrent .futures .wait (futures )
292+ thread_pool .shutdown (wait = True )
293+ thread_pool = None
283294
284295
285296if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments