This commit is contained in:
yumoqing 2026-04-14 10:38:05 +08:00
parent aedab9abff
commit 0859f8162d

View File

@ -137,23 +137,23 @@ class DBPools:
self._pools[name] = pool self._pools[name] = pool
self.e_except = None self.e_except = None
sqlor = None sqlor = None
try: async with pool.context() as sqlor:
async with pool.context() as sqlor: try:
await sqlor.enter() await sqlor.enter()
yield sqlor yield sqlor
if sqlor and sqlor.dataChanged:
await sqlor.commit()
await sqlor.exit() await sqlor.exit()
if sqlor and sqlor.dataChanged: except Exception as e:
await sqlor.commit() self.e_except = e
except Exception as e: cb = format_exc()
self.e_except = e exception(f'sqlorContext():EXCEPTION{e}, {cb}')
cb = format_exc() try:
exception(f'sqlorContext():EXCEPTION{e}, {cb}') await sqlor.rollback()
try: except:
await sqlor.rollback() pass
except: await sqlor.exit()
pass raise e
await sqlor.exit()
raise e
def get_exception(self): def get_exception(self):
return self.e_except return self.e_except