From db6260394a794b0b29fe78186f32f3c1a12ccae7 Mon Sep 17 00:00:00 2001 From: Keisuke ANDO Date: Fri, 16 Oct 2026 08:26:24 +0900 Subject: [PATCH 1/2] Make resource module import optional for Windows --- src/adf_core_python/launcher.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/adf_core_python/launcher.py b/src/adf_core_python/launcher.py index c3a111b..c4089fb 100644 --- a/src/adf_core_python/launcher.py +++ b/src/adf_core_python/launcher.py @@ -1,5 +1,9 @@ import argparse -import resource + +try: + import resource +except ImportError: + resource = None from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.agent_launcher import AgentLauncher @@ -12,13 +16,14 @@ def __init__( self, launcher_config_file: str, ) -> None: - try: - resource.setrlimit(resource.RLIMIT_NOFILE, (8192, 1048576)) - except Exception as e: - print( - f"Failed to set resource limit: {e}. " - "This may cause issues with the number of open files." - ) + if resource is not None: + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (8192, 1048576)) + except Exception as e: + print( + f"Failed to set resource limit: {e}. " + "This may cause issues with the number of open files." + ) self.launcher_config = Config(launcher_config_file) From 733567b8fa7fca1d65c5c3f3c36cf94e99321350 Mon Sep 17 00:00:00 2001 From: Keisuke ANDO Date: Fri, 16 Oct 2026 14:04:42 +0900 Subject: [PATCH 2/2] Use sys.platform check for resouces import to satisfy mypy --- src/adf_core_python/launcher.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/adf_core_python/launcher.py b/src/adf_core_python/launcher.py index c4089fb..c44f23c 100644 --- a/src/adf_core_python/launcher.py +++ b/src/adf_core_python/launcher.py @@ -1,9 +1,8 @@ import argparse +import sys -try: +if sys.platform != "win32": import resource -except ImportError: - resource = None from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.agent_launcher import AgentLauncher @@ -16,7 +15,7 @@ def __init__( self, launcher_config_file: str, ) -> None: - if resource is not None: + if sys.platform != "win32": try: resource.setrlimit(resource.RLIMIT_NOFILE, (8192, 1048576)) except Exception as e: