From f7421c456acfbba48a0cc13adc44a6edccd17484 Mon Sep 17 00:00:00 2001 From: winterhuan Date: Thu, 16 Jul 2026 15:51:06 +0800 Subject: [PATCH] fix(scheduler): move singleton lock port off Windows reserved range 45762 falls inside the WinNAT dynamically-excluded port range on some Windows machines (Hyper-V/WSL/Docker). bind() there fails with 10048 (and 10013/EACCES even with SO_REUSEADDR) despite no process holding the port, so the scheduler could never start on those hosts. Switch the lock port to 41537, which is outside the common reserved ranges. Co-Authored-By: Claude Fable 5 --- reflect/scheduler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reflect/scheduler.py b/reflect/scheduler.py index a3ca622d3..c2fab4901 100644 --- a/reflect/scheduler.py +++ b/reflect/scheduler.py @@ -3,10 +3,13 @@ # 端口锁:防止重复启动,bind失败时agentmain会直接崩溃退出 # reload时mod.__dict__保留_lock,跳过重复绑定 +# 注意:原端口 45762 在部分 Windows 机器上落入系统保留段(Hyper-V/WSL/Docker +# 的 WinNAT 动态排除),此时没有任何进程占用,bind 却报 10048(带 SO_REUSEADDR +# 甚至报 10013/EACCES)。改用 41537,避开常见保留段。 try: _lock except NameError: _lock = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) - _lock.bind(('127.0.0.1', 45762)); _lock.listen(1) + _lock.bind(('127.0.0.1', 41537)); _lock.listen(1) INTERVAL = 120 ONCE = False