Skip to content

Commit 8638ca1

Browse files
authored
Merge pull request #1045 from Pythagora-io/fix-run-command-output
process manager: fix getting command output
2 parents bd0afbe + 8089347 commit 8638ca1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/proc/process_manager.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,15 @@ async def _nonblock_read(reader: asyncio.StreamReader, timeout: float) -> str:
9090
:param timeout: Timeout for the read operation (should not be too long).
9191
:return: Data read from the stream reader, or empty string.
9292
"""
93-
try:
94-
data = await asyncio.wait_for(reader.read(), timeout)
95-
return data.decode("utf-8", errors="ignore")
96-
except asyncio.TimeoutError:
97-
return ""
93+
buffer = ""
94+
while True:
95+
try:
96+
data = await asyncio.wait_for(reader.read(1), timeout)
97+
if not data:
98+
return buffer
99+
buffer += data.decode("utf-8", errors="ignore")
100+
except asyncio.TimeoutError:
101+
return buffer
98102

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

0 commit comments

Comments
 (0)