]> git.ipfire.org Git - pbs.git/commitdiff
builders: Fetch the builder again on message
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 12:47:52 +0000 (12:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 12:47:52 +0000 (12:47 +0000)
This is necessary because this will be launched in a new task. Since we
cannot use the object from a different session, we have to fetch the
builder again.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/builders.py

index 5cbb149d290c370dfa0c63b4e55453f47484bb1a..25d9b6c11f476434602492aa7abb1d27ff894149 100644 (file)
@@ -33,6 +33,10 @@ 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)