From 0859f8162de4327f112ac39b4b878bbb8c37ca83 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 14 Apr 2026 10:38:05 +0800 Subject: [PATCH] bugfix --- sqlor/dbpools.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sqlor/dbpools.py b/sqlor/dbpools.py index fbe76c5..3b804e3 100755 --- a/sqlor/dbpools.py +++ b/sqlor/dbpools.py @@ -137,23 +137,23 @@ class DBPools: self._pools[name] = pool self.e_except = None sqlor = None - try: - async with pool.context() as sqlor: + async with pool.context() as sqlor: + try: await sqlor.enter() yield sqlor + if sqlor and sqlor.dataChanged: + await sqlor.commit() await sqlor.exit() - if sqlor and sqlor.dataChanged: - await sqlor.commit() - except Exception as e: - self.e_except = e - cb = format_exc() - exception(f'sqlorContext():EXCEPTION{e}, {cb}') - try: - await sqlor.rollback() - except: - pass - await sqlor.exit() - raise e + except Exception as e: + self.e_except = e + cb = format_exc() + exception(f'sqlorContext():EXCEPTION{e}, {cb}') + try: + await sqlor.rollback() + except: + pass + await sqlor.exit() + raise e def get_exception(self): return self.e_except