Bugfix mqtt socket error (#6256)

This commit is contained in:
Pascal Vizeli 2017-02-26 23:43:02 +01:00 committed by Paulus Schoutsen
parent 61909e873f
commit 5932446508

View File

@ -394,8 +394,7 @@ class MQTT(object):
self.progress = {} self.progress = {}
self.birth_message = birth_message self.birth_message = birth_message
self._mqttc = None self._mqttc = None
self._subscribe_lock = asyncio.Lock(loop=hass.loop) self._paho_lock = asyncio.Lock(loop=hass.loop)
self._publish_lock = asyncio.Lock(loop=hass.loop)
if protocol == PROTOCOL_31: if protocol == PROTOCOL_31:
proto = mqtt.MQTTv31 proto = mqtt.MQTTv31
@ -435,7 +434,7 @@ class MQTT(object):
This method must be run in the event loop and returns a coroutine. This method must be run in the event loop and returns a coroutine.
""" """
with (yield from self._publish_lock): with (yield from self._paho_lock):
yield from self.hass.loop.run_in_executor( yield from self.hass.loop.run_in_executor(
None, self._mqttc.publish, topic, payload, qos, retain) None, self._mqttc.publish, topic, payload, qos, retain)
@ -485,7 +484,7 @@ class MQTT(object):
if topic in self.topics: if topic in self.topics:
return return
with (yield from self._subscribe_lock): with (yield from self._paho_lock):
result, mid = yield from self.hass.loop.run_in_executor( result, mid = yield from self.hass.loop.run_in_executor(
None, self._mqttc.subscribe, topic, qos) None, self._mqttc.subscribe, topic, qos)