提交 984ae86d 编写于 作者: J Jason Swails 提交者: Roger Light

Clean up stray exceptions following broker disconnect with TLS (#51)

Python 3.4 started raising ValueError instead of AttributeError when writing to
a disconnected SSL socket. When the client writes some stray messages following
a call to disconnect(), they are not caught in Python 3.4 or Python 3.5.
Signed-off-by: NJason Swails <jason.swails@gmail.com>
上级 01cc0139
......@@ -1325,10 +1325,10 @@ class Client(object):
Messages that match 'sub' will be passed to 'callback'. Any
non-matching messages will be passed to the default on_message
callback.
Call multiple times with different 'sub' to define multiple topic
specific callbacks.
Topic specific callbacks may be removed with
message_callback_remove()."""
if callback is None or sub is None:
......@@ -1501,7 +1501,7 @@ class Client(object):
write_length = self._ssl.write(packet['packet'][packet['pos']:])
else:
write_length = self._sock.send(packet['packet'][packet['pos']:])
except AttributeError:
except (AttributeError, ValueError):
self._current_out_packet_mutex.release()
return MQTT_ERR_SUCCESS
except socket.error as err:
......@@ -2340,7 +2340,7 @@ class Client(object):
raise ssl.SSLError('Certificate subject does not match remote hostname.')
# Compatibility class for easy porting from mosquitto.py.
# Compatibility class for easy porting from mosquitto.py.
class Mosquitto(Client):
def __init__(self, client_id="", clean_session=True, userdata=None):
super(Mosquitto, self).__init__(client_id, clean_session, userdata)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册