This commit is contained in:
yumoqing 2019-08-29 15:28:59 +08:00
parent d47ae51269
commit 74c3b0dc29

View File

@ -213,11 +213,17 @@ class DBPools:
sor = await self.getSqlor(dbname)
try:
ret = await func(sor,dbname,*args,**kw)
try:
await sor.conn.commit()
except:
pass
return ret
except Exception as e:
print('error',sor)
sor.conn.rollback()
try:
await sor.conn.rollback()
except:
pass
raise e
finally:
await self.freeSqlor(sor)
@ -232,14 +238,20 @@ class DBPools:
try:
desc = await func(dbname,NS,callback=callback,**kw)
ret = await sor.runSQL(desc,NS,callback,**kw)
try:
await sor.conn.commit()
except:
pass
if NS.get('dummy'):
return NS['dummy']
else:
return []
except Exception as e:
print('error:',e)
try:
await sor.conn.rollback()
except:
pass
raise e
finally:
await self.freeSqlor(sor)