Commits

Ivan Zakrevsky  committed d9baef8

prevent lock_tags() if not nonrepeatable_reads

  • Participants
  • Parent commits 91b00cc

Comments (0)

Files changed (1)

File cache_tagging/tagging.py

 
     def lock_tags(self, tags, version=None):
         """Locks tags for concurrent transactions."""
-        date = datetime.now()
-        timeout = TAG_LOCKING_TIMEOUT
-        if self.delay:
-            timeout += self.delay
-        self.cache.set_many(
-            {self.get_locked_tag_name(tag): date for tag in tags},
-            timeout,
-            version
-        )
+        if self.nonrepeatable_reads:
+            date = datetime.now()
+            timeout = TAG_LOCKING_TIMEOUT
+            if self.delay:
+                timeout += self.delay
+            self.cache.set_many(
+                {self.get_locked_tag_name(tag): date for tag in tags},
+                timeout,
+                version
+            )
 
     def is_locked_any_tag(self, tags, version=None):
         """Returns True, if current transaction has been started earlier than