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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

