Skip to content

Commit

Permalink
Commits an atomic cache after a SQL commit (not before).
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Oct 13, 2014
1 parent ab6152d commit be4e723
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cachalot/monkey_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,15 @@ def inner(self):
def patch_exit(original):
@wraps(original)
def inner(self, exc_type, exc_value, traceback):
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 connection.needs_rollback:
if exc_type is None and not needs_rollback:
atomic_cache.commit()

original(self, exc_type, exc_value, traceback)

inner.original = original
return inner

Expand Down

0 comments on commit be4e723

Please sign in to comment.