Add select_for_update() to improve isolation

This commit is contained in:
Andrew Godwin 2016-04-05 22:18:54 -07:00
parent 732167282b
commit 4504eb6ec9

View File

@ -60,7 +60,7 @@ class DatabaseChannelLayer(object):
while True:
try:
with transaction.atomic():
message = self.channel_model.objects.filter(channel__in=channels).order_by("id").first()
message = self.channel_model.objects.select_for_update().filter(channel__in=channels).order_by("id").first()
if message:
self.channel_model.objects.filter(pk=message.pk).delete()
return message.channel, self.deserialize(message.content)