diff --git a/out_service/cd.py b/out_service/cd.py index 47ff7200..b50f8dc7 100644 --- a/out_service/cd.py +++ b/out_service/cd.py @@ -73,12 +73,12 @@ class JSONRequestHandler(BaseHTTPRequestHandler): def connect_and_send(): nonlocal sc sc = sc_all[addr] - if sc is None: - sc = socket.socket() - sc.settimeout(5) # 设置超时 - sc.connect((host, int(port))) - sc_all[f"{host}_{port}"] = sc try: + if sc is None: + sc = socket.socket() + sc.settimeout(5) # 设置超时 + sc.connect((host, int(port))) + sc_all[f"{host}_{port}"] = sc sc.sendall(b"R") except Exception as e: try: