Thank you. So you are saying that each request basically does: sql BEGIN ... call appropriate controller function ... sql COMMIT if success
What I do not understand is: 1) When called from cron, there is no automatic begin transaction, so where does the begin come from? 2) When my controller function calls commit, how do I get another begin to make a new transaction? On Dec 29, 7:18 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > A transaction starts when a request arrive and it is committed when a > request returns. If there is an error that it not caught the > transaction is rolledback. > > You can insert db.commit() (and db.rollback()) everywhere to break the > transaction in smaller parts. > > Massimo > > On Dec 29, 8:54 pm, toomim <too...@gmail.com> wrote: > > > > > Mossimo, unfortunately this proposal does not solve the multi- > > threading problem. > > > Can you tell me what the semantics of the "implicit begin" is? The > > problem is that I do not know where begin is inserted. I thought it > > happened at the beginning of every controller function call. That > > would make it impossible to do multiple transactions (with multiple > > begins) inside a single function. Is that assumption incorrect? > > > On Dec 29, 1:14 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > Attention. There is no db.begin(). it is implicit. You can commit > > > automatically but why not: > > > > while queue is not empty: > > > task = db(~status.belongs(('done','failed'))).select(limitby= > > > (0,1))[0] > > > success = do_long_thing(task) > > > if success: > > > task.update(status = 'done') > > > else: > > > task.update(status = 'failed') > > > > On Dec 29, 2:10 pm, toomim <too...@gmail.com> wrote: > > > > > Very clever, thank you! If it crashes, these items will be lost > > > > though. Is there a way to use transactions, to pull a single item at > > > > a time from the table, process and delete it, within a single > > > > transaction? Something like this: > > > > > while queue is not empty: > > > > db.begin() > > > > task = db(status != 'done').select(limitby=(0,1))[0] > > > > task.update(status = 'done') > > > > success = do_long_thing(task) > > > > if success: > > > > db.commit() > > > > else: > > > > db.rollback() > > > > > This way if the code fires an exception, or the computer crashes, the > > > > database will roll back to its prior state automatically. The problem > > > > is there is no begin statement in web2py. All begin statements seem > > > > to be automatic. Is it possible to do one manually? Can I turn off > > > > the automatic one? > > > > > On Dec 29, 12:04 am, Thadeus Burgess <thade...@thadeusb.com> wrote: > > > > > > Ah yes, so back to my original thought > > > > > > db(status == 'pending').update(status = 'pending-' + request.now) > > > > > > for db(status == 'pending-' + request.now).select(): > > > > > task.update_record(status = 'processing-' + request.now > > > > > success = do_the_long_thing(task) > > > > > fail > > > > > if success: > > > > > task.update_record(status = 'done') > > > > > > -Thadeus > > > > > > On Tue, Dec 29, 2009 at 1:52 AM, toomim <too...@gmail.com> wrote: > > > > > > sk.update_record(status == 'proce -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.