Skip to content

Commit f2de326

Browse files
committed
add error msg
1 parent 4fc848c commit f2de326

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

eval_protocol/pytest/default_mcp_gym_rollout_processor.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ def start(self) -> None:
4242
if self.process:
4343
return
4444

45+
try:
46+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
47+
s.settimeout(1)
48+
result = s.connect_ex(("localhost", self.port))
49+
if result == 0:
50+
raise RuntimeError(
51+
f"Port {self.port} is already in use! Please use a different port or kill the process using it."
52+
)
53+
except socket.error:
54+
pass
55+
4556
# Set environment for server
4657
env = os.environ.copy()
4758
env["PORT"] = str(self.port)

0 commit comments

Comments
 (0)