From 07846f7bec67c9a752510fd4dfd51414349f2589 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 14 Jun 2016 09:33:45 -0400 Subject: [PATCH] ignore closing file error when file not open fixes #16268 --- lib/ansible/plugins/cache/jsonfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index a99f5a3e318..1bf0ea10b6e 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -101,7 +101,10 @@ class CacheModule(BaseCacheModule): else: f.write(jsonify(value)) finally: - f.close() + try: + f.close() + except UnboundLocalError: + pass def has_expired(self, key):