From 941b36b24259009a6be5ed5e56744729b0b67262 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 3 May 2025 11:39:09 +0000 Subject: [PATCH] builders: Make handling log messages actually fast We don't need to fetch the build object here which saves us from opening and closing an entire database session which is not really needed. Signed-off-by: Michael Tremer --- src/web/builders.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/web/builders.py b/src/web/builders.py index afcecee2..ea7f1e70 100644 --- a/src/web/builders.py +++ b/src/web/builders.py @@ -53,10 +53,6 @@ class APIv1ControlHandler(base.APIMixin, base.BackendMixin, tornado.websocket.We self.builder.disconnected() async def on_message(self, message): - # Fetch the builder again, because this is being executed as a separate task - # and therefore we cannot use the object from the previous session. - builder = await self.backend.builders.get_by_name(self.builder.name) - # Decode message message = self._decode_json_message(message) @@ -68,8 +64,12 @@ class APIv1ControlHandler(base.APIMixin, base.BackendMixin, tornado.websocket.We if type == "log": return self.backend.logstreams.log(message) + # Fetch the builder again, because this is being executed as a separate task + # and therefore we cannot use the object from the previous session. + builder = await self.backend.builders.get_by_name(self.builder.name) + # Handle stats - elif type == "stats": + if type == "stats": async with await self.db.transaction(): await builder.log_stats(**data) -- 2.47.2