Skip to content

Commit 7a1a68d

Browse files
jdDavid Bouchare
authored andcommitted
config: do not leak file descriptor when reading config (DataDog#425)
Makes sure that the config file descriptor is closed once read.
1 parent 3b9ab39 commit 7a1a68d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

datadog/util/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def get_config(cfg_path=None, options=None):
113113

114114
config_path = get_config_path(cfg_path, os_name=get_os())
115115
config = configparser.ConfigParser()
116-
config.readfp(skip_leading_wsp(open(config_path)))
116+
with open(config_path) as config_file:
117+
config.readfp(skip_leading_wsp(config_file))
117118

118119
# bulk import
119120
for option in config.options('Main'):

0 commit comments

Comments
 (0)