From e4d2f4d14182b5cd8d88dc34ee1fc8c847c75849 Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Fri, 29 Mar 2024 16:37:26 -0700 Subject: [PATCH] [scope][leak] Fix config file descriptor leak. --- torcharrow/scope.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/torcharrow/scope.py b/torcharrow/scope.py index a4c6dee2e..ec9a063f3 100644 --- a/torcharrow/scope.py +++ b/torcharrow/scope.py @@ -56,7 +56,8 @@ def __init__(self, config: ty.Union[dict, str, None] = None): self.config = type(self).default_config elif isinstance(config, str): path = config - self.config = {**type(self).default_config, **json.load(open(path))} + with open(path) as f: + self.config = {**type(self).default_config, **json.load(f)} elif isinstance(config, dict): self.config = {**type(self).default_config, **config}