Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions xprocess/xprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ class ProcessStarter(ABC):
popen_kwargs = {}
max_read_lines = 50
terminate_on_interrupt = False
pattern_match = None

def __init__(self, control_dir, process):
self._max_time = None
Expand Down Expand Up @@ -421,8 +422,13 @@ def wait_pattern(self, log_file):
"""Wait until the pattern is mached and callback returns successful."""
raw_lines = self.get_lines(log_file)
lines = map(self.log_line, self.filter_lines(raw_lines))
has_match = any(re.search(self.pattern, line) for line in lines)
return has_match
first_match = next(
match
for match in (re.search(self.pattern, line) for line in lines)
if match
)
self.pattern_match = first_match
return first_match

def filter_lines(self, lines):
"""fetch first <max_read_lines>, ignoring blank lines."""
Expand Down