diff options
| 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 | 
| commit | e14b4f67e20b5ea8d6a3fd4d4b67064a7251abb4 (patch) | |
| tree | 77bd5fdb5d731d9f27bb814d97a2afbc8a1143ba /archaeological_context_records/models.py | |
| parent | 13a3311ff045b53dbdced2b03dce7295d3c1a398 (diff) | |
| download | Ishtar-e14b4f67e20b5ea8d6a3fd4d4b67064a7251abb4.tar.bz2 Ishtar-e14b4f67e20b5ea8d6a3fd4d4b67064a7251abb4.zip | |
Geodata post save: transactions and targeted post save to limit deadlocks
Diffstat (limited to 'archaeological_context_records/models.py')
| -rw-r--r-- | archaeological_context_records/models.py | 15 | 
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 | 
