[ci] try to log process using the port to debug the port usage (#7711)

This commit is contained in:
youkaichao
2024-08-20 17:41:12 -07:00
committed by GitHub
parent 66a9e713a7
commit b74a125800
2 changed files with 17 additions and 0 deletions

View File

@@ -547,6 +547,16 @@ def get_open_port() -> int:
return s.getsockname()[1]
def find_process_using_port(port: int) -> Optional[psutil.Process]:
for conn in psutil.net_connections():
if conn.laddr.port == port:
try:
return psutil.Process(conn.pid)
except psutil.NoSuchProcess:
return None
return None
def update_environment_variables(envs: Dict[str, str]):
for k, v in envs.items():
if k in os.environ and os.environ[k] != v: