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.