New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sqlalchemy-bot opened this Issue Dec 10, 2012 · 2 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Dec 10, 2012

Migrated issue, originally created by Michael Bayer (zzzeek)

#!python

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)

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Dec 10, 2012

Michael Bayer (zzzeek) wrote:

c9c29f4

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Dec 10, 2012

Changes by Michael Bayer (zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment