diff options
-rw-r--r-- | kvmd/apps/kvmd/server.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py index 5520b13e..b8d3aa3a 100644 --- a/kvmd/apps/kvmd/server.py +++ b/kvmd/apps/kvmd/server.py @@ -335,9 +335,11 @@ class Server: # pylint: disable=too-many-instance-attributes async def __log_handler(self, request: aiohttp.web.Request) -> aiohttp.web.StreamResponse: seek = valid_log_seek(request.query.get("seek", "0")) follow = valid_bool(request.query.get("follow", "false")) - response = aiohttp.web.StreamResponse(status=200, reason="OK", headers={"Content-Type": "text/plain"}) - await response.prepare(request) + response: Optional[aiohttp.web.StreamResponse] = None async for record in self.__log_reader.poll_log(seek, follow): + if response is None: + response = aiohttp.web.StreamResponse(status=200, reason="OK", headers={"Content-Type": "text/plain"}) + await response.prepare(request) await response.write(("[%s %s] --- %s" % ( record["dt"].strftime("%Y-%m-%d %H:%M:%S"), record["service"], |