Skip to content
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
Closed
Labels
bug Something isn't working high priority

Comments

@sqlalchemy-bot
Copy link

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
Copy link
Author

Michael Bayer (zzzeek) wrote:

c9c29f4

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added bug Something isn't working high priority labels Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

1 participant