This commit is contained in:
yumoqing 2019-10-22 21:23:46 +08:00
parent e7654d597a
commit 3401a26acf

View File

@ -259,20 +259,29 @@ class DBPools:
def runSQL(self,func): def runSQL(self,func):
@wraps(func) @wraps(func)
async def wrap_func(dbname,NS,*args,**kw): async def wrap_func(dbname,NS,*args,**kw):
print('runSQL:1')
sor, commit = await self.useOrGetSor(dbname,**kw) sor, commit = await self.useOrGetSor(dbname,**kw)
print('runSQL:2')
kw['sor'] = sor kw['sor'] = sor
ret = None ret = None
try: try:
print('runSQL:3')
desc = await func(dbname,NS,*args,**kw) desc = await func(dbname,NS,*args,**kw)
print('runSQL:4')
callback = kw.get('callback',None) callback = kw.get('callback',None)
kw1 = {} kw1 = {}
[ kw1.update({k:v}) for k,v in kw.items() if k!='callback' ] [ kw1.update({k:v}) for k,v in kw.items() if k!='callback' ]
print('runSQL:5')
ret = await sor.runSQL(desc,NS,callback,**kw1) ret = await sor.runSQL(desc,NS,callback,**kw1)
print('runSQL:6')
if commit: if commit:
try: try:
print('runSQL:7')
await sor.conn.commit() await sor.conn.commit()
print('runSQL:8')
except: except:
pass pass
print('runSQL:9')
if NS.get('dummy'): if NS.get('dummy'):
return NS['dummy'] return NS['dummy']
else: else:
@ -288,6 +297,7 @@ class DBPools:
raise e raise e
finally: finally:
if commit: if commit:
print('runSQL:10')
await self.freeSqlor(sor) await self.freeSqlor(sor)
return wrap_func return wrap_func