From d72a1521953b8bf36d95da39fc0688ca644da458 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 15 Dec 2018 15:38:58 -0500 Subject: [PATCH] run transaction interactions now return a result --- torba/client/basedatabase.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/torba/client/basedatabase.py b/torba/client/basedatabase.py index b6ead4aea..722bb9de1 100644 --- a/torba/client/basedatabase.py +++ b/torba/client/basedatabase.py @@ -54,12 +54,13 @@ class AIOSQLite: def __run_transaction(self, fun: Callable[[sqlite3.Connection, Any, Any], Any], *args, **kwargs): self.connection.execute('begin') try: - fun(self.connection, *args, **kwargs) # type: ignore - except (Exception, OSError): + result = fun(self.connection, *args, **kwargs) # type: ignore + self.connection.commit() + return result + except (Exception, OSError) as e: + log.exception('Error running transaction:', exc_info=e) self.connection.rollback() raise - else: - self.connection.commit() def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):