From cba03ea059ceb98bf7972f6753a7fda0ea7a6b2e Mon Sep 17 00:00:00 2001 From: Azamatkhan Arifkhanov <60036464+Sm1Ling@users.noreply.github.com> Date: Sat, 23 Aug 2025 22:47:40 +0300 Subject: [PATCH 1/2] Update model.py Added closing of save_fds. --- flaml/automl/model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flaml/automl/model.py b/flaml/automl/model.py index dcde0927ab..fdb355f2c7 100644 --- a/flaml/automl/model.py +++ b/flaml/automl/model.py @@ -2832,5 +2832,6 @@ def __exit__(self, *_): os.dup2(self.save_fds[0], 1) os.dup2(self.save_fds[1], 2) # Close the null files - os.close(self.null_fds[0]) - os.close(self.null_fds[1]) + for fd in self.null_fds + self.save_fds: + os.close(fd) + From 62fd72c2c7ef055276ffde598f4db198841dd4e8 Mon Sep 17 00:00:00 2001 From: Sm1Ling Date: Mon, 25 Aug 2025 13:16:17 +0300 Subject: [PATCH 2/2] Updated model.py for pre-commit requirements --- flaml/automl/model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flaml/automl/model.py b/flaml/automl/model.py index fdb355f2c7..298f3cab80 100644 --- a/flaml/automl/model.py +++ b/flaml/automl/model.py @@ -2820,7 +2820,7 @@ def __init__(self): # Open a pair of null files self.null_fds = [os.open(os.devnull, os.O_RDWR) for x in range(2)] # Save the actual stdout (1) and stderr (2) file descriptors. - self.save_fds = (os.dup(1), os.dup(2)) + self.save_fds = [os.dup(1), os.dup(2)] def __enter__(self): # Assign the null pointers to stdout and stderr. @@ -2834,4 +2834,3 @@ def __exit__(self, *_): # Close the null files for fd in self.null_fds + self.save_fds: os.close(fd) -