fix: enable SO_REUSEADDR on socket to prevent address binding errors in benchmark utility

This commit is contained in:
Donato Capitella
2026-05-15 09:22:06 +01:00
parent adf72bdda7
commit d1e5e0b3b0
+1
View File
@@ -154,6 +154,7 @@ def check_port_free(port: int) -> bool:
"""Check if a port is free. If not, identify and report what's using it."""
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
s.bind(("127.0.0.1", port))
return True