On 03/05/16 14:08, Gavin Wahl wrote:
 >     with MyModel.objects.lock():
 >         ... do stuff ...

This is misleading as it implies the lock is released when the context
manager exists, but in postgres at least the lock will be held until the
end of the transaction.

Hah!  Shows how much I know about table locking :P

What advantage does implementing an ORM API for table locking have over
`cursor.execute("LOCK TABLE mymodel")`?

Much the same as the rest of the ORM API : Abstraction and convenience.

Even if it's just so you can pass a ModelClass instead of having to know the table name... and avoid having to access cursor directly.

Perhaps transaction.lock_table(model) since, as you say, it's related to the term of the transaction?

--
Curtis

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/57282559.2080408%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to