feat: cd.py清空缓冲区后再执行
This commit is contained in:
parent
17996a0b86
commit
47cfa7ce17
|
@ -79,6 +79,16 @@ class JSONRequestHandler(BaseHTTPRequestHandler):
|
|||
sc.settimeout(5) # 设置超时
|
||||
sc.connect((host, int(port)))
|
||||
sc_all[addr] = sc
|
||||
# 清空接收缓冲区
|
||||
sc.settimeout(0.1) # 设置短暂超时
|
||||
for _ in range(5):
|
||||
try:
|
||||
data = sc.recv(65536)
|
||||
if not data:
|
||||
break
|
||||
except (socket.timeout, BlockingIOError):
|
||||
break
|
||||
sc.settimeout(5) # 恢复原超时设置
|
||||
sc.sendall(b"R")
|
||||
return sc
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue