You probably need to add db.commit() to your cron job to commit the transaction. This is necessary in external scripts, but not in models, views, and controllers. See http://web2py.com/book/default/chapter/06#commit-and-rollback and http://web2py.com/book/default/chapter/04#Cron.
Anthony On Monday, December 12, 2011 4:50:13 PM UTC-5, frasse wrote: > > Hi > I have two function one is running in controller when users access the > page (manageGame) and one is running as cron job (cleanDB). I am > geting "Lock wait timeout exceeded; Try restarting transaction" > error in mysql database. > How can I avoid this problem ? > > def manageGame(): > now = datetime.datetime.now() > activeBigGame = db((db.games.LotteryDrawTime > now) & > (db.games.Type == 'Big Game') & (db.games.active == 'Yes')).select() > activeone_of_7 = db((db.games.Type == '1 of 7')& (db.games.active > == 'Yes') & (db.games.LotteryDrawTime > now)).select() > db(db.games.LotteryDrawTime < now).update(active = 'No') > ...... > > > def cleanDB(now): > db((db.games.LotteryDrawTime < now) &(db.games.numberPlayer == > 0) ).delete() > > Thanx Frasse > >