Commit 79075925 authored by 方开's avatar 方开 🍔
Browse files

修复socket接收超时触发的异常

parent ee166aa1
......@@ -166,7 +166,7 @@ def checkData(data: bytes, houseType: str, measureType: str, pointnum):
def measureClient(sendAddr, cmd, measureType, houseType="multi", pointnum=None, timeout=50):
try:
# 设置一个带有超时异常的tcp客户端
with gevent.Timeout(timeout, False) as timeout:
with gevent.Timeout(timeout, exception=TimeoutError):
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
logging.info(f"正在向{sendAddr}发送指令{cmd}")
tcpSocket.connect(sendAddr)
......
......@@ -165,7 +165,7 @@ def checkData(data: bytes, houseType: str, measureType: str, pointnum):
def measureClient(sendAddr, cmd, measureType, houseType="multi", pointnum=None, timeout=50):
try:
# 设置一个带有超时异常的tcp客户端
with gevent.Timeout(timeout, False) as timeout:
with gevent.Timeout(timeout, exception=TimeoutError):
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
logging.info(f"正在向{sendAddr}发送指令{cmd}")
tcpSocket.connect(sendAddr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment