Commits

Mike Bayer committed b7e610b

further cleanup

Comments (0)

Files changed (2)

dogpile/dogpile.py

         if not self.is_expired:
             return
 
-        has_createlock = False
         if self.has_value:
             if not self.dogpilelock.acquire(False):
                 log.debug("dogpile entering block while another thread does the create")
                 return
-            log.debug("dogpile create lock acquired")
-            has_createlock = True
-
-        if not has_createlock:
+        else:
             log.debug("no value, waiting for create lock")
             self.dogpilelock.acquire()
-            log.debug("waited for create lock")
+        try:
+            log.debug("value creation lock acquired")
 
-        try:
             # see if someone created the value already
             if not self.is_expired:
                 return

tests/test_dogpile.py

             if slow_write_time:
                 with dogpile.acquire_write_lock():
                     saved = list(the_resource)
+                    # clear out the resource dict so that
+                    # usage threads hitting it will
+                    # raise
                     the_resource[:] = []
                     time.sleep(slow_write_time)
                     the_resource[:] = saved
                     # establish "max stale" as, object expired + time 
                     # to create a new one + 10%
                     max_stale = (expiretime + creation_time) * 1.1
-
-                    assert time_since_create < max_stale
-                    "Value is %f seconds old, expiretime %f, time to create %f" % (
-                        time_since_create, expiretime, creation_time
-                    )
+                    assert time_since_create < max_stale, \
+                        "Value is %f seconds old, expiretime %f, time to create %f" % (
+                            time_since_create, expiretime, creation_time
+                        )
                     log.debug("time since create %s max stale time %s" % (
                         time_since_create,
                         max_stale
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.