diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-08-24 15:41:51 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-08-24 15:41:51 -0400 |
commit | c80135c7f76c8c2118025f22a478a292d66ee9b3 (patch) | |
tree | b443679bf3d40010a660cd1c326b514d61c3e8e6 | |
parent | 0cb2276155932b9fd5d98f8b2a823e734d006e25 (diff) | |
download | dogpile-core-c80135c7f76c8c2118025f22a478a292d66ee9b3.tar.gz |
refine the conditionals
-rw-r--r-- | dogpile/dogpile.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/dogpile/dogpile.py b/dogpile/dogpile.py index 7e48869..65ae6e0 100644 --- a/dogpile/dogpile.py +++ b/dogpile/dogpile.py @@ -103,7 +103,8 @@ class Dogpile(object): @property def is_expired(self): - """Return true if the expiration time is reached.""" + """Return true if the expiration time is reached, or no value is available.""" + return not self.has_value or \ time.time() - self.createdtime > self.expiretime @@ -113,9 +114,8 @@ class Dogpile(object): return self.createdtime > 0 def _enter(self, creator): - if self.has_value: - if not self.is_expired: - return + if not self.is_expired: + return has_createlock = False if self.has_value: @@ -132,9 +132,8 @@ class Dogpile(object): try: # see if someone created the value already - if self.has_value: - if not self.is_expired: - return + if not self.is_expired: + return log.debug("Calling creation function") creator() |