1. Michael Bayer
  2. dogpile.cache
  3. Issues
Issue #15 resolved

file backend isn't using context manager correctly in locking code

Michael Bayer
repo owner created an issue
diff -r 2421b6447c65442f6ae0d410629382701da035c3 dogpile/cache/backends/file.py
--- a/dogpile/cache/backends/file.py    Tue Nov 20 17:48:17 2012 -0500
+++ b/dogpile/cache/backends/file.py    Mon Dec 10 14:11:24 2012 -0500
@@ -213,14 +213,18 @@
     @contextmanager
     def read(self):
         self.acquire_read_lock(True)
-        yield
-        self.release_read_lock()
+        try:
+            yield
+        finally:
+            self.release_read_lock()

     @contextmanager
     def write(self):
         self.acquire_write_lock(True)
-        yield
-        self.release_write_lock()
+        try:
+            yield
+        finally:
+            self.release_write_lock()

     def acquire_read_lock(self, wait):
         return self._acquire(wait, os.O_RDONLY, fcntl.LOCK_SH)