mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
streamer: read full stdout
This commit is contained in:
parent
ed067c80cf
commit
f89918b4bf
@ -106,17 +106,17 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
logger.info("Started streamer pid=%d: %s", proc.pid, cmd)
|
logger.info("Started streamer pid=%d: %s", proc.pid, cmd)
|
||||||
|
|
||||||
empty = 0
|
empty = 0
|
||||||
while proc.returncode is None:
|
async for line_bytes in proc.stdout: # type: ignore
|
||||||
line = (await proc.stdout.readline()).decode(errors="ignore").strip()
|
line = line_bytes.decode(errors="ignore").strip()
|
||||||
if line:
|
if line:
|
||||||
logger.info("streamer: %s", line)
|
logger.info("Streamer: %s", line)
|
||||||
empty = 0
|
empty = 0
|
||||||
else:
|
else:
|
||||||
empty += 1
|
empty += 1
|
||||||
if empty == 100: # asyncio bug
|
if empty == 100: # asyncio bug
|
||||||
break
|
raise RuntimeError("Streamer/asyncio: too many empty lines")
|
||||||
|
|
||||||
raise RuntimeError("WTF")
|
raise RuntimeError("Streamer unexpectedly died")
|
||||||
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user