Browse Source

Use with statement to enforce file close

We found some race conditions at overcloud deploy, looks like after
running 55-heat-config, the -notify.json files are not there yet.

This review enforce a close() of the file with a with statement

Change-Id: I7d342893d790efa798ff8df379c6942eca5b7ec3
tags/1.8.0
Quique Llorente 9 months ago
parent
commit
64b57bfef7
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      heat-config/bin/heat-config-notify

+ 2
- 1
heat-config/bin/heat-config-notify View File

@@ -97,7 +97,8 @@ def main(argv=sys.argv, stdin=sys.stdin):
97 97
         log.error(usage)
98 98
         return 1
99 99
 
100
-    c = json.load(open(conf_file))
100
+    with open(conf_file, mode='r') as f:
101
+        c = json.load(f)
101 102
 
102 103
     iv = dict((i['name'], i['value']) for i in c['inputs'])
103 104
 

Loading…
Cancel
Save