Commits an atomic cache after a SQL commit (not before).

This commit is contained in:
Bertrand Bordage 2014-10-13 20:57:36 +02:00
parent ab6152dfb1
commit be4e723b3f

View file

@ -240,13 +240,15 @@ def _patch_atomic():
def patch_exit(original):
@wraps(original)
def inner(self, exc_type, exc_value, traceback):
nested_caches = NESTED_CACHES[cachalot_settings.CACHALOT_CACHE]
atomic_cache = nested_caches.pop()
if exc_type is None and not connection.needs_rollback:
atomic_cache.commit()
needs_rollback = connection.needs_rollback
original(self, exc_type, exc_value, traceback)
nested_caches = NESTED_CACHES[cachalot_settings.CACHALOT_CACHE]
atomic_cache = nested_caches.pop()
if exc_type is None and not needs_rollback:
atomic_cache.commit()
inner.original = original
return inner