On Wednesday, March 20, 2019 at 9:56:11 PM UTC-4, João Matos wrote:
>
> What I read about the commit/rollback "wrapping" that web2py does, it 
> doesn't seem to solve my problem.
>
> Let me explain.
> I have 3 tables (sn_counter, wo_counter and wo).
> The procedure I must do is the following:
> 1. Get the record from wo_counter table a extract the counter value (read 
> operation), let's suppose I get the number 10.
>

At this step, you can lock this particular wo_counter record using 
for_update:

row = db(query).select(db.wo_counter.counter, for_update=True).first()

The above will (a) wait until the relevant rows are unlocked via a similar 
query in another request before doing the select and then (b) lock the 
relevant rows until the current transaction is complete. So, once you've 
read the counter value, you can proceed with the rest of the transaction 
without worrying about other requests making intervening changes.

Anthony

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to