Fix "address already in use" on server restart (Linux/macOS)

This commit is contained in:
oobabooga 2026-04-05 05:55:39 -07:00
parent 422f42ca7f
commit d78fc46114
2 changed files with 25 additions and 2 deletions

View file

@ -373,6 +373,7 @@ class LlamaServer:
"""Check if a port is available for use."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', port))
return True
except OSError: