diff --git a/doc/changelog.d/4611.fixed.md b/doc/changelog.d/4611.fixed.md new file mode 100644 index 00000000000..0bcd606c110 --- /dev/null +++ b/doc/changelog.d/4611.fixed.md @@ -0,0 +1 @@ +Fix the slurm-launcher hang by closing stdout after reading diff --git a/src/ansys/fluent/core/launcher/slurm_launcher.py b/src/ansys/fluent/core/launcher/slurm_launcher.py index 08a7683a8cf..d0c72b854a7 100644 --- a/src/ansys/fluent/core/launcher/slurm_launcher.py +++ b/src/ansys/fluent/core/launcher/slurm_launcher.py @@ -70,6 +70,7 @@ import time from typing import Any, Callable, Dict +from ansys.fluent.core import config from ansys.fluent.core._types import PathType from ansys.fluent.core.exceptions import InvalidArgument from ansys.fluent.core.launcher.launch_options import ( @@ -102,6 +103,10 @@ def _get_slurm_job_id(proc: subprocess.Popen): for line in proc.stdout: if line.startswith(prefix.encode()): line = line.decode().removeprefix(prefix).strip() + # if the configuration setting 'launch_fluent_stdout' is None, + # close proc.stdout after reading the slurm job id to avoid hang in some systems + if config.launch_fluent_stdout is None and proc.stdout is not None: + proc.stdout.close() return int(line)