Created
May 10, 2016 19:51
-
-
Save bcoca/cecca870587adb052cb8cc4b2bd51cd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py | |
index f0ec635..4cc2b55 100644 | |
--- a/lib/ansible/plugins/cache/jsonfile.py | |
+++ b/lib/ansible/plugins/cache/jsonfile.py | |
@@ -62,13 +62,16 @@ class CacheModule(BaseCacheModule): | |
return None | |
def get(self, key): | |
- | |
- if self.has_expired(key) or key == "": | |
- raise KeyError | |
+ ''' This checks the in memory cache first as the fact was not expired at 'gather time' | |
+ and it would be problematic if the key did expire after some long running tasks and | |
+ user gets 'undefined' error in the same play ''' | |
if key in self._cache: | |
return self._cache.get(key) | |
+ if self.has_expired(key) or key == "": | |
+ raise KeyError | |
+ | |
cachefile = "%s/%s" % (self._cache_dir, key) | |
try: | |
with codecs.open(cachefile, 'r', encoding='utf-8') as f: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment