MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / setup_debug

Function setup_debug

eval_code/recons/models/pi3/utils/debug.py:40–63  ·  view source on GitHub ↗
(is_main_process=True, max_retries=10, port_range=(10000, 20000))

Source from the content-addressed store, hash-verified

38 return s.connect_ex((host, port)) == 0
39
40def setup_debug(is_main_process=True, max_retries=10, port_range=(10000, 20000)):
41 if is_main_process:
42 host = os.environ['SLURM_NODELIST'].split(',')[0]
43
44 for _ in range(max_retries):
45 port = random.randint(*port_range)
46 try:
47 if is_port_in_use(host, port):
48 print(f"Port {port} is already in use, trying another...")
49 continue
50
51 # 更新 launch.json
52 update_vscode_launch_file(host, port)
53
54 print("master_addr = ", host)
55 debugpy.listen((host, port))
56 print(f"Waiting for debugger attach at port {port}...", flush=True)
57 debugpy.wait_for_client()
58 print("Debugger attached", flush=True)
59 return
60 except Exception as e:
61 print(f"Failed to bind to port {port}: {e}")
62
63 raise RuntimeError("Could not find a free port for debugpy after several attempts.")

Callers

nothing calls this directly

Calls 2

is_port_in_useFunction · 0.70

Tested by

no test coverage detected