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

process manager: fix getting command output #1045

Merged
merged 1 commit into from
Jul 4, 2024
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
14 changes: 9 additions & 5 deletions core/proc/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ async def _nonblock_read(reader: asyncio.StreamReader, timeout: float) -> str:
:param timeout: Timeout for the read operation (should not be too long).
:return: Data read from the stream reader, or empty string.
"""
try:
data = await asyncio.wait_for(reader.read(), timeout)
return data.decode("utf-8", errors="ignore")
except asyncio.TimeoutError:
return ""
buffer = ""
while True:
try:
data = await asyncio.wait_for(reader.read(1), timeout)
if not data:
return buffer
buffer += data.decode("utf-8", errors="ignore")
except asyncio.TimeoutError:
return buffer

async def read_output(self, timeout: float = NONBLOCK_READ_TIMEOUT) -> tuple[str, str]:
new_stdout = await self._nonblock_read(self._process.stdout, timeout)
Expand Down
Loading