feat: cd BrokenPipeError时尝试再建立连接
This commit is contained in:
parent
bd9d5a5dc2
commit
370c905781
|
@ -22,6 +22,13 @@ def get_tyy_data_t(host, port):
|
||||||
try:
|
try:
|
||||||
sc = socket.socket()
|
sc = socket.socket()
|
||||||
sc.connect((host, int(port)))
|
sc.connect((host, int(port)))
|
||||||
|
except BrokenPipeError:
|
||||||
|
try:
|
||||||
|
sc.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
sc = socket.socket()
|
||||||
|
sc.connect((host, int(port)))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
cache.set(cd_thread_key, {"err_msg": f"采集器连接失败-{str(e)}"})
|
cache.set(cd_thread_key, {"err_msg": f"采集器连接失败-{str(e)}"})
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
|
@ -52,7 +59,7 @@ def get_tyy_data(*args):
|
||||||
num = 0
|
num = 0
|
||||||
while True:
|
while True:
|
||||||
num += 1
|
num += 1
|
||||||
if num > 6:
|
if num > 8:
|
||||||
break
|
break
|
||||||
val = cache.get(cd_thread_key)
|
val = cache.get(cd_thread_key)
|
||||||
if isinstance(val, dict):
|
if isinstance(val, dict):
|
||||||
|
|
Loading…
Reference in New Issue