diff options
author | Devaev Maxim <[email protected]> | 2020-10-10 08:10:37 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-10-10 08:10:37 +0300 |
commit | 69509349bde314e89101f1825dfda9292fb5acb7 (patch) | |
tree | 320e52564b81ed76396106b9982eec42598a087a /kvmd/aioproc.py | |
parent | cf5bc84872d4e865bdf96198b40fda47f7f285a2 (diff) |
refactoring
Diffstat (limited to 'kvmd/aioproc.py')
-rw-r--r-- | kvmd/aioproc.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kvmd/aioproc.py b/kvmd/aioproc.py index 65502d35..ecf6230e 100644 --- a/kvmd/aioproc.py +++ b/kvmd/aioproc.py @@ -56,6 +56,19 @@ async def log_process(cmd: List[str], logger: logging.Logger) -> asyncio.subproc return proc +async def log_stdout_infinite(proc: asyncio.subprocess.Process, logger: logging.Logger) -> None: # pylint: disable=no-member + empty = 0 + async for line_bytes in proc.stdout: # type: ignore + line = line_bytes.decode(errors="ignore").strip() + if line: + logger.info("Console: %s", line) + empty = 0 + else: + empty += 1 + if empty == 100: # asyncio bug + raise RuntimeError("asyncio process: too many empty lines") + + def ignore_sigint() -> None: signal.signal(signal.SIGINT, signal.SIG_IGN) |