From 976be675e5da409001173b6d974a284c5911a8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 7 Sep 2016 11:57:10 +0200 Subject: [PATCH] Declare cache_key before trying to access it --- src/octoprint/server/util/flask.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 630ddb5b..bd35f857 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -334,6 +334,8 @@ def cached(timeout=5 * 60, key=lambda: "view:%s" % flask.request.path, unless=No def decorated_function(*args, **kwargs): logger = logging.getLogger(__name__) + cache_key = key() + def f_with_duration(*args, **kwargs): start_time = time.time() try: @@ -355,7 +357,6 @@ def cached(timeout=5 * 60, key=lambda: "view:%s" % flask.request.path, unless=No logger.debug("Cache for {path} disabled, calling wrapped function".format(path=flask.request.path)) return f_with_duration(*args, **kwargs) - cache_key = key() rv = _cache.get(cache_key) # only take the value from the cache if we are not required to refresh it from the wrapped function