Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
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))
# Close the session
await session.close()
+ # Re-raise the exception
+ if exception:
+ raise exception
+
async def transaction(self):
"""
Opens a new transaction