Skip to content

Commit

Permalink
tools_parser.py: return booleans indicating the success of parsers in…
Browse files Browse the repository at this point in the history
…stead of using os.exit
  • Loading branch information
AlyaGomaa committed Aug 5, 2024
1 parent 054bc84 commit 5f51dd1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modes/tools_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ def get_supported_tools(self) -> Tuple[str]:
supported_tools.add(parser.tool_name)
return supported_tools

def start_parsers(self):
def start_parsers(self) -> bool:
"""
runs each parser in a separate proc and returns when they're all done
:param print_stats_event: the thread will set this event when it's
done reading the ground truth flows and
started reading slips and suricata flows so the print_stats
thread can start printing
:return: 0 if all good, 1 if an error occured
returns True if all parsers started and ended successfully
"""
# the gt parsers should finish first before starting tool parsers
processes: List[Process] = self.start_gt_parsers()
for proc in processes:
proc.join()
if proc.exitcode != 0:
# terminate, dont start the rest of the parsers
os._exit(1)
return False

self.print_stats_event.set()

Expand All @@ -131,9 +131,10 @@ def start_parsers(self):
proc.join()
if proc.exitcode != 0:
# terminate, dont start the rest of the parsers
os._exit(1)
return False
return True

os._exit(0)




Expand Down

0 comments on commit 5f51dd1

Please sign in to comment.