@@ -80,7 +80,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
8080 None if it cannot be determined.
8181 """
8282 try :
83- result = Run ().capture (cmake_path , "-E" , "capabilities" )
83+ result = Run (timeout = 2 ).capture (cmake_path , "-E" , "capabilities" )
8484 try :
8585 version = Version (
8686 json .loads (result .stdout )["version" ]["string" ].split ("-" )[0 ]
@@ -91,7 +91,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
9191 logger .warning ("Could not determine CMake version, got {!r}" , result .stdout )
9292 except subprocess .CalledProcessError :
9393 try :
94- result = Run ().capture (cmake_path , "--version" )
94+ result = Run (timeout = 2 ).capture (cmake_path , "--version" )
9595 try :
9696 version = Version (
9797 result .stdout .splitlines ()[0 ].split ()[- 1 ].split ("-" )[0 ]
@@ -111,6 +111,8 @@ def get_cmake_program(cmake_path: Path) -> Program:
111111 )
112112 except PermissionError :
113113 logger .warning ("Permissions Error getting CMake's version" )
114+ except subprocess .TimeoutExpired :
115+ logger .warning ("Accessing CMake timed out, ignoring" )
114116
115117 return Program (cmake_path , None )
116118
@@ -133,8 +135,12 @@ def get_ninja_programs(*, module: bool = True) -> Generator[Program, None, None]
133135 """
134136 for ninja_path in _get_ninja_path (module = module ):
135137 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+ ):
138144 yield Program (ninja_path , None )
139145 continue
140146
0 commit comments