feat: cd 设置清空缓冲区

This commit is contained in:
caoqianming 2025-06-23 17:00:39 +08:00
parent 108fe0ae9f
commit 8e33e084b4
1 changed files with 9 additions and 0 deletions

View File

@ -148,6 +148,15 @@ def get_tyy_data(*args):
sc.settimeout(5) # 设置超时
sc.connect((host, port))
sc_all[f"{host}_{port}"] = sc
else:
# 清空接收缓冲区
sc.settimeout(0.1) # 设置短暂超时
try:
while True:
sc.recv(1024)
except (socket.timeout, BlockingIOError):
pass
sc.settimeout(5) # 恢复原超时设置
sc.sendall(b"R")
except BrokenPipeError:
if retry > 0: