@@ -80,7 +80,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
80
80
None if it cannot be determined.
81
81
"""
82
82
try :
83
- result = Run ().capture (cmake_path , "-E" , "capabilities" )
83
+ result = Run (timeout = 2 ).capture (cmake_path , "-E" , "capabilities" )
84
84
try :
85
85
version = Version (
86
86
json .loads (result .stdout )["version" ]["string" ].split ("-" )[0 ]
@@ -91,7 +91,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
91
91
logger .warning ("Could not determine CMake version, got {!r}" , result .stdout )
92
92
except subprocess .CalledProcessError :
93
93
try :
94
- result = Run ().capture (cmake_path , "--version" )
94
+ result = Run (timeout = 2 ).capture (cmake_path , "--version" )
95
95
try :
96
96
version = Version (
97
97
result .stdout .splitlines ()[0 ].split ()[- 1 ].split ("-" )[0 ]
@@ -111,6 +111,8 @@ def get_cmake_program(cmake_path: Path) -> Program:
111
111
)
112
112
except PermissionError :
113
113
logger .warning ("Permissions Error getting CMake's version" )
114
+ except subprocess .TimeoutExpired :
115
+ logger .warning ("Accessing CMake timed out, ignoring" )
114
116
115
117
return Program (cmake_path , None )
116
118
@@ -133,8 +135,12 @@ def get_ninja_programs(*, module: bool = True) -> Generator[Program, None, None]
133
135
"""
134
136
for ninja_path in _get_ninja_path (module = module ):
135
137
try :
136
- result = Run ().capture (ninja_path , "--version" )
137
- except (subprocess .CalledProcessError , PermissionError ):
138
+ result = Run (timeout = 2 ).capture (ninja_path , "--version" )
139
+ except (
140
+ subprocess .CalledProcessError ,
141
+ PermissionError ,
142
+ subprocess .TimeoutExpired ,
143
+ ):
138
144
yield Program (ninja_path , None )
139
145
continue
140
146
0 commit comments