mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-13 10:18:49 +02:00
Add socket timeout to is_port_in_use() to fix ~280s startup delay on WSL2 (#2077)
On WSL2 with networkingMode=mirrored, connect_ex() to non-listening ports gets black-holed through the Windows host networking stack instead of returning ECONNREFUSED. Without a timeout, TCP SYN retransmits with exponential backoff (1+2+4+8+16+32+64 ≈ 127s per port), causing Router Mode's port scan of 15001-15010 to stall for ~280 seconds on startup. Adding a 1-second timeout makes connect_ex() fail fast, reducing startup from ~303s to ~23s on affected systems. Tested on WSL2 Ubuntu 24.04 with mirrored networking, KoboldCpp v1.110, RTX 3090 Ti, Qwen3.5-27B Q4_K_M.
This commit is contained in:
@@ -2898,6 +2898,7 @@ def websearch(query):
|
||||
def is_port_in_use(portNum):
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.settimeout(1)
|
||||
return s.connect_ex(('localhost', portNum)) == 0
|
||||
except Exception:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user