Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled wait_output() to search from latest log buffer #3597

Merged
merged 1 commit into from
Jan 12, 2025
Merged
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
8 changes: 7 additions & 1 deletion lisa/util/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def __init__(

# add a string stream handler to the logger
self.log_buffer = io.StringIO()
self.log_buffer_offset = 0

@_retry_spawn
def start(
Expand Down Expand Up @@ -488,6 +489,7 @@ def wait_output(
timeout: int = 300,
error_on_missing: bool = True,
interval: float = 1,
delta_only: bool = False,
) -> bool:
# check if stdout buffers contain the string "keyword" to determine if
# it is running
Expand All @@ -499,11 +501,15 @@ def wait_output(
self._stderr_writer.flush()

# check if buffer contains the keyword
if keyword in self.log_buffer.getvalue():
find_pos = self.log_buffer_offset if delta_only else 0
if self.log_buffer.getvalue().find(keyword, find_pos) >= 0:
self.log_buffer_offset = len(self.log_buffer.getvalue())
return True

time.sleep(interval)

self.log_buffer_offset = len(self.log_buffer.getvalue())

if error_on_missing:
raise LisaException(
f"{keyword} not found in stdout after {timeout} seconds"
Expand Down
Loading