database update not executed in Exception

12 views
Skip to first unread message

Yebach

unread,
Jan 30, 2018, 3:26:41 AM1/30/18
to web2py-users
Hello

In my try-Except block I have a db update to update database back to initial value if code fail. Looks like update is not executed.

except Exception as e:
"Če je napaka pri ustavljanju woshi engina"
#db.rollback()
db(db.scripts.id == scriptId).update(sc_status = 10)
db.commit()
print db._lastsql
print "skripta %s v status 10!" %(str(scriptId))
"pobrišemo tudi datoteke ker drugače bo engine še kr laufov"
#Pobiršem out file če obstaja v mapi engine/e1 in sc_engine_out
count = 0
outPath= os.path.join(request.folder, 'engine', 'e1', str(scriptId) + '.out')
while (count < 5 and ( os.path.isfile(outPath))):
count += 1
os.remove(outPath)
time.sleep(0.05)

count = 0
llsFle = os.path.join(request.folder, 'engine', 'e1', str(scriptId) + '.lls')
while (count < 5 and (os.path.isfile(llsFle))):
count += 1
os.remove(llsFle)
time.sleep(0.05)


exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
errmsg = ["error pri parseOut funkciji", exc_type, fname, exc_tb.tb_lineno,e.__doc__ , e.message]
print "errmsg ", errmsg
print(exc_type, fname, exc_tb.tb_lineno)
print e.__doc__
print e.message
#Writte error to log file
exceptionLogger(errmsg, scriptId, org, auth.user_id)
return {"error" : 666}



I tried with db.rollback() and it is the same. The print is shown, also the sql UPDATE scripts SET sc_status=10 WHERE (scripts.id = 434); is correct  and it works if executed on database.

any suggestions??

thank you

Reply all
Reply to author
Forward
0 new messages