From 1fa49fd813be52411dbc9a9c2f3a1d7f9c3360cd Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Mon, 22 Sep 2025 10:16:12 -0400 Subject: [PATCH 1/2] Store matching pattern in ProcessStarter.pattern_match Fix #160 --- xprocess/xprocess.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xprocess/xprocess.py b/xprocess/xprocess.py index 0df85f4..33f6c4e 100644 --- a/xprocess/xprocess.py +++ b/xprocess/xprocess.py @@ -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 @@ -421,8 +422,9 @@ 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 , ignoring blank lines.""" From b0b927182657d2497e663564af88adf2ecfab35e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:17:23 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xprocess/xprocess.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xprocess/xprocess.py b/xprocess/xprocess.py index 33f6c4e..4fd4f65 100644 --- a/xprocess/xprocess.py +++ b/xprocess/xprocess.py @@ -422,7 +422,11 @@ 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)) - first_match = next(match for match in (re.search(self.pattern, line) for line in lines) if 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