From cb758700b72eabdea4c459a49a9a83dc70b9aa92 Mon Sep 17 00:00:00 2001 From: mw0000001 <108394021+mw0000001@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:29:18 +0200 Subject: [PATCH] Update computemgtd.py Fix for closing filehandle of tempfile and delete it. (mkstemp, is not closing os filehandle automatically) computemgtd was running into a too many open files issue before, every ~8 days. Which made compute node be restarted. --- src/slurm_plugin/computemgtd.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/slurm_plugin/computemgtd.py b/src/slurm_plugin/computemgtd.py index e590bc222..460a37158 100644 --- a/src/slurm_plugin/computemgtd.py +++ b/src/slurm_plugin/computemgtd.py @@ -17,7 +17,7 @@ from datetime import datetime, timezone from logging.config import fileConfig from subprocess import CalledProcessError -from tempfile import mkstemp +from tempfile import NamedTemporaryFile from botocore.config import Config from common.schedulers.slurm_commands import get_nodes_info @@ -55,7 +55,8 @@ class ComputemgtdConfig: } def __init__(self, config_file_path): - _, self._local_config_file = mkstemp() + tf = NamedTemporaryFile() + self._local_config_file = tf.name self._get_config(config_file_path) def __repr__(self):