Skip to content

Commit

Permalink
Fix these UnboundLocalError
Browse files Browse the repository at this point in the history
Also fix a bug where self.expire was used instead of cached_expiry
  • Loading branch information
Kyria committed May 27, 2018
1 parent 94d4018 commit f55b0b1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions esipy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ def __get_or_create_app(self, url, cache_key):

if cached_app is not None and cached_headers is not None:
# we didn't set custom expire, use header expiry
if self.expire is None:
expires = cached_headers.get('expires', None)
if expires is not None:

cache_timeout = get_cache_time_left(
cached_headers['expires']
)
if cache_timeout >= 0:
return cached_app
expires = cached_headers.get('expires', None)
cache_timeout = -1
if self.expire is None and expires is not None:
cache_timeout = get_cache_time_left(
cached_headers['expires']
)
if cache_timeout >= 0:
return cached_app

# we set custom expire, check this instead
else:
Expand All @@ -86,7 +85,7 @@ def __get_or_create_app(self, url, cache_key):

# if nothing makes us use the cache, invalidate it
if ((expires is None or cache_timeout < 0 or
0 < self.expire < time.time()) and etag is None):
cached_expiry < time.time()) and etag is None):
self.cache.invalidate(cache_key)

# set timeout value in case we have to cache it later
Expand Down

0 comments on commit f55b0b1

Please sign in to comment.