File tree Expand file tree Collapse file tree
components/job-orchestration/job_orchestration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import signal
44import subprocess
55import sys
6+ import logging
67from contextlib import closing
78from logging import Logger
89from pathlib import Path
@@ -101,6 +102,8 @@ def sigterm_handler(_signo, _stack_frame):
101102 clo_log_file .close ()
102103 if 0 != return_code :
103104 log_file_contents (logger , clo_log_path )
105+ else :
106+ log_file_contents (logger , clo_log_path , logging .INFO )
104107 duration = (datetime .datetime .now () - start_time ).total_seconds ()
105108
106109 update_query_task_metadata (
Original file line number Diff line number Diff line change 44import os
55import subprocess
66import sys
7+ from concurrent .futures import ThreadPoolExecutor , as_completed
78from pathlib import Path
89from typing import TextIO
910import logging
@@ -92,13 +93,18 @@ def main(argv: list[str]) -> int:
9293 f" Concurrency={ concurrency } "
9394 f" Upsert Interval={ parsed_args .upsert_interval } "
9495 )
95- for i , reducer in enumerate (reducers ):
96- reducer .communicate ()
97- logger .info (f"reducer-{ i } exited with returncode={ reducer .returncode } " )
98- for i , reducer_log_file in enumerate (reducer_log_files ):
99- reducer_log_file .close ()
100- log_file_path = logs_dir / f"reducer-{ i } .log"
101- log_file_contents (logger , log_file_path , logging .INFO )
96+ with ThreadPoolExecutor (max_workers = concurrency ) as executor :
97+ futures = {
98+ executor .submit (reducers [i ].communicate ): i for i in range (concurrency )
99+ }
100+ for future in as_completed (futures ):
101+ i = futures [future ]
102+ future .result ()
103+ logger .info (f"reducer-{ i } exited with returncode={ reducers [i ].returncode } " )
104+ if logs_dir is not None :
105+ reducer_log_files [i ].close ()
106+ log_file_path = logs_dir / f"reducer-{ i } .log"
107+ log_file_contents (logger , log_file_path , logging .INFO )
102108
103109 logger .error ("All reducers terminated" )
104110
You can’t perform that action at this time.
0 commit comments