mirror of
https://github.com/norohind/SquadsActivityMonitor.git
synced 2026-10-22 17:12:08 +03:00
model fix: rollback transaction on fail
This commit is contained in:
1 file changed
+7
-1
@@ -18,13 +18,19 @@ logger.propagate = False
|
||||
|
||||
def errors_catcher(func: callable) -> callable:
|
||||
def decorated(*args, **kwargs):
|
||||
self: PostgresModel = args[0]
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
|
||||
except psycopg2.InterfaceError:
|
||||
args[0].open_model()
|
||||
self.open_model() # args[0] - self
|
||||
result = func(*args, **kwargs)
|
||||
|
||||
except Exception:
|
||||
# just reset transaction at least
|
||||
self.db.rollback()
|
||||
raise
|
||||
|
||||
return result
|
||||
|
||||
return decorated
|
||||
|
||||
Reference in new issue
Block a user