MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / _test_cdp_connection

Method _test_cdp_connection

tools/cdp_browser.py:227–248  ·  view source on GitHub ↗

Test if CDP connection is available

(self, debug_port: int)

Source from the content-addressed store, hash-verified

225 return browser_path
226
227 async def _test_cdp_connection(self, debug_port: int) -> bool:
228 """
229 Test if CDP connection is available
230 """
231 try:
232 # Simple socket connection test
233 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
234 s.settimeout(5)
235 result = s.connect_ex(("localhost", debug_port))
236 if result == 0:
237 utils.logger.info(
238 f"[CDPBrowserManager] CDP port {debug_port} is accessible"
239 )
240 return True
241 else:
242 utils.logger.warning(
243 f"[CDPBrowserManager] CDP port {debug_port} is not accessible"
244 )
245 return False
246 except Exception as e:
247 utils.logger.warning(f"[CDPBrowserManager] CDP connection test failed: {e}")
248 return False
249
250 async def _launch_browser(self, browser_path: str, headless: bool):
251 """

Callers 2

_launch_browserMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected