]> git.ipfire.org Git - pbs.git/commitdiff
database: (Re-)raise any exceptions after the task is done
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2025 13:53:40 +0000 (13:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2025 13:53:40 +0000 (13:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/database.py

index e2742d92d20ae4fff6d71816b3023ab4b5ed10e1..c380b2b9c747e4eb0a2f0ea9abeec86e3c265c1a 100644 (file)
@@ -240,8 +240,11 @@ class Connection(object):
                except KeyError:
                        return
 
-               # If there was no exception, we can commit
-               if not task.exception():
+               # Fetch any exception
+               exception = task.exception()
+
+               # If there is no exception, we can commit
+               if exception is None:
                        await session.commit()
 
                log.debug("Releasing database session %s of %s" % (session, task))
@@ -252,6 +255,10 @@ class Connection(object):
                # Close the session
                await session.close()
 
+               # Re-raise the exception
+               if exception:
+                       raise exception
+
        async def transaction(self):
                """
                        Opens a new transaction