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