that would be very aggressive locking to use everywhere. Sounds
unusual that every single SELECT you have is causing concurrency
problems, because if you lock on everything like that you greatly
increase your risk of deadlocks which is not much better.
you can alter the state of the Query object across the board using the
before_compile event:
http://docs.sqlalchemy.org/en/latest/orm/events.html#sqlalchemy.orm.events.QueryEvents.before_compile
@event.listens_for(Query, 'before_compile', retval=True)
def receive_before_compile(query):
query = query.with_for_update()
return query
but that is likely going to lead to problems, that will impact ALL
selects, including lazy loads, refreshes, etc.
this is not quite the same thing but maybe just using REPEATABLE READ
or even SERIALIZABLE isolation is an immediate workaround to reduce
concurrency conflicts.
>
> Thanks!
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
>
http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See
http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sqlalchemy+...@googlegroups.com.
> To post to this group, send email to
sqlal...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/sqlalchemy.
> For more options, visit
https://groups.google.com/d/optout.