My code has roughly the following form, and I am wondering if this can generate a race condition or if the first insert happens right away:
def receive_webhook(): def POST(*args, **vars): db.webhook_table.insert(webhook_data=data, status=0) scheduler.queue_task(process_update) #....some other code happens after this The code in my Scheduler.py: def process_update(): import json record = db(db.webhook_table.status == 0).select(limitby=(0, 1), orderby=~db.webhook_table.create_date).as_list() # CAN THIS SELECT FINISH BEFORE THE INSERT FROM receive_webhook IS RECORDED IN THE DB OR IS THE INSERT FINISHED IMMEDIATEDLY state = json.loads(record[0]['webhook_data'])['status'] if not state == 'Updated': db(db.webhook_table.id == record[0]['id']).update(status=2) db.commit() from gluon.scheduler import Scheduler scheduler = Scheduler(db) Can this create a race condition? If so what is the best way to fix it so that it can't? The status update(status=2) from the second code block appears to be executing sometimes but not all the time. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.