mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
More stable explicit file close. (#34303)
This commit is contained in:
parent
0eb2644c1c
commit
70fd5d4caf
1 changed files with 4 additions and 2 deletions
|
@ -118,9 +118,11 @@ def get_host_groups(inventory, refresh=False, cloud=None):
|
|||
(cache_file, cache_expiration_time) = get_cache_settings(cloud)
|
||||
if is_cache_stale(cache_file, cache_expiration_time, refresh=refresh):
|
||||
groups = to_json(get_host_groups_from_cloud(inventory))
|
||||
open(cache_file, 'w').write(groups)
|
||||
with open(cache_file, 'w') as f:
|
||||
f.write(groups)
|
||||
else:
|
||||
groups = open(cache_file, 'r').read()
|
||||
with open(cache_file, 'r') as f:
|
||||
groups = f.read()
|
||||
return groups
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue