Skip to content

Commit 8ed5b8a

Browse files
authored
Merge pull request #162 from NONONOexe/fix/windows-resource-import
Fix ModuleNotFoundError on Windows by making resource import optional
2 parents 0ab215a + 733567b commit 8ed5b8a

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎src/adf_core_python/launcher.py‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import argparse
2-
import resource
2+
import sys
3+
4+
if sys.platform != "win32":
5+
import resource
36

47
from adf_core_python.core.config.config import Config
58
from adf_core_python.core.launcher.agent_launcher import AgentLauncher
@@ -12,13 +15,14 @@ def __init__(
1215
self,
1316
launcher_config_file: str,
1417
) -> None:
15-
try:
16-
resource.setrlimit(resource.RLIMIT_NOFILE, (8192, 1048576))
17-
except Exception as e:
18-
print(
19-
f"Failed to set resource limit: {e}. "
20-
"This may cause issues with the number of open files."
21-
)
18+
if sys.platform != "win32":
19+
try:
20+
resource.setrlimit(resource.RLIMIT_NOFILE, (8192, 1048576))
21+
except Exception as e:
22+
print(
23+
f"Failed to set resource limit: {e}. "
24+
"This may cause issues with the number of open files."
25+
)
2226

2327
self.launcher_config = Config(launcher_config_file)
2428

0 commit comments

Comments
 (0)