summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-10-26 17:05:38 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:19 +0100
commit1c88b774262c698fe9d09528834b641a67ae91e3 (patch)
tree77bd5fdb5d731d9f27bb814d97a2afbc8a1143ba /archaeological_context_records
parent47700369c77b35a59fcf38d3246e57e24e84964f (diff)
downloadIshtar-1c88b774262c698fe9d09528834b641a67ae91e3.tar.bz2
Ishtar-1c88b774262c698fe9d09528834b641a67ae91e3.zip
Geodata post save: transactions and targeted post save to limit deadlocks
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/models.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 97a629d05..55b101acc 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -23,10 +23,9 @@ import uuid
from django.apps import apps
from django.conf import settings
from django.contrib.gis.db import models
-from django.contrib.gis.geos import Point
from django.contrib.postgres.indexes import GinIndex
from django.contrib.sites.models import Site
-from django.db import connection
+from django.db import connection, IntegrityError, transaction
from django.db.models import Q
from django.db.models.signals import post_delete, post_save, m2m_changed
from django.urls import reverse
@@ -458,11 +457,15 @@ class GeographicSubTownItem(GeoItem):
return
if not q_geodata_current_town.filter(source_id=town.id).count():
- self.geodata.add(town.main_geodata)
+ try:
+ # multiple save, post treatments can cause synchronous add
+ with transaction.atomic():
+ self.geodata.add(town.main_geodata)
+ except IntegrityError:
+ pass
if save:
- self.skip_history_when_saving = True
- self._no_move = True
- self.save()
+ post_save_geo(self.__class__, instance=self, created=False,
+ update_fields=False, raw=False, using="default")
else:
return True