The solution I ended up going with was using a PostgreSQL table lock:
@contextmanager
@transaction.atomic
def lock_table(model):
"""Performs a table lock on the provided model.
Note that this locks the entire table for the given model
and prevents any other operations from occurring on that
model.
Assume the following models for this question:
class Jurisdiction(models.Model):
name = models.CharField(max_length = 100)
class Account(models.Model):
account_number = models.PositiveIntegerField(blank = True)
jurisdiction = models.ForeignKey("Jurisdiction", on_delete = models.
CASCA
2 matches
Mail list logo