From: Michael Tremer Date: Sun, 26 Jan 2025 13:53:40 +0000 (+0000) Subject: database: (Re-)raise any exceptions after the task is done X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f9eba3af9c294a388d4985fbfc78b551060358b;p=pbs.git database: (Re-)raise any exceptions after the task is done Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/database.py b/src/buildservice/database.py index e2742d92..c380b2b9 100644 --- a/src/buildservice/database.py +++ b/src/buildservice/database.py @@ -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