Skip to content

Commit

Permalink
Using concurrent process executor to run compute in parallel (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Sunil Muthuswamy <[email protected]>
  • Loading branch information
sunilmut and sunilmut authored Feb 17, 2024
1 parent 3cd340d commit 10bd8f5
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 169 deletions.
18 changes: 18 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# globals
logger = None
input_dir = ""
logs = []


def convert_obj_to_nan(val: object) -> object:
Expand Down Expand Up @@ -248,13 +249,30 @@ def __init__(self):
def set_result_log_ui_box(self, result_log_ui_box):
self.result_log_ui_box = result_log_ui_box

def flush_logs(self, logs):
if self.result_log_ui_box is None:
return

for record in logs:
level = record[0]
msg = record[1]
match level:
case logging.WARNING:
# If it wasn't previously set to higher attention.
if not self.result_log_ui_box.bg == LIGHT_RED_COLOR:
self.result_log_ui_box.bg = LIGHT_YELLOW_COLOR
case logging.CRITICAL | logging.ERROR:
self.result_log_ui_box.bg = LIGHT_RED_COLOR
self.result_log_ui_box.value += msg

def emit(self, record):
"""
Writes the message to the output file (or the default logger stream),
stdout and the UI result text box
"""
try:
msg = self.format(record)
logs.append([record.levelno, msg])
match record.levelno:
case logging.WARNING:
p_msg = bcolors.WARN + msg + bcolors.ENDC
Expand Down
Loading

0 comments on commit 10bd8f5

Please sign in to comment.