mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
commit
68713822fd
@ -129,5 +129,8 @@ def _read(path):
|
||||
|
||||
def _write(path, data):
|
||||
"""Write YAML helper."""
|
||||
# Do it before opening file. If dump causes error it will now not
|
||||
# truncate the file.
|
||||
data = dump(data)
|
||||
with open(path, 'w', encoding='utf-8') as outfile:
|
||||
outfile.write(dump(data))
|
||||
outfile.write(data)
|
||||
|
@ -393,8 +393,7 @@ class MQTT(object):
|
||||
self.progress = {}
|
||||
self.birth_message = birth_message
|
||||
self._mqttc = None
|
||||
self._subscribe_lock = asyncio.Lock(loop=hass.loop)
|
||||
self._publish_lock = asyncio.Lock(loop=hass.loop)
|
||||
self._paho_lock = asyncio.Lock(loop=hass.loop)
|
||||
|
||||
if protocol == PROTOCOL_31:
|
||||
proto = mqtt.MQTTv31
|
||||
@ -434,9 +433,10 @@ class MQTT(object):
|
||||
|
||||
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(
|
||||
None, self._mqttc.publish, topic, payload, qos, retain)
|
||||
yield from asyncio.sleep(0, loop=self.hass.loop)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_connect(self):
|
||||
@ -484,9 +484,10 @@ class MQTT(object):
|
||||
if topic in self.topics:
|
||||
return
|
||||
|
||||
with (yield from self._subscribe_lock):
|
||||
with (yield from self._paho_lock):
|
||||
result, mid = yield from self.hass.loop.run_in_executor(
|
||||
None, self._mqttc.subscribe, topic, qos)
|
||||
yield from asyncio.sleep(0, loop=self.hass.loop)
|
||||
|
||||
_raise_on_error(result)
|
||||
self.progress[mid] = topic
|
||||
|
@ -2,7 +2,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 39
|
||||
PATCH_VERSION = '0'
|
||||
PATCH_VERSION = '1'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user