mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
* feat: add agent manager to manage all agents; * extract the host ssh port to prevent conflict. * clean all containers with prefix is sandbox- * merge from upstream/main * merge from upstream/main * Update frontend/src/state/settingsSlice.ts * Update opendevin/sandbox/ssh_box.py * Update opendevin/sandbox/exec_box.py --------- Co-authored-by: Robert Brennan <accounts@rbren.io>
16 lines
363 B
Python
16 lines
363 B
Python
import socket
|
|
|
|
|
|
def find_available_tcp_port() -> int:
|
|
"""Find an available TCP port, return -1 if none available.
|
|
"""
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
try:
|
|
sock.bind(('localhost', 0))
|
|
port = sock.getsockname()[1]
|
|
return port
|
|
except Exception:
|
|
return -1
|
|
finally:
|
|
sock.close()
|