Merge pull request #6272 from home-assistant/release-0-39-1

0.39.1
This commit is contained in:
Paulus Schoutsen 2017-02-26 20:48:57 -08:00 committed by GitHub
commit 68713822fd
3 changed files with 10 additions and 6 deletions

View File

@ -129,5 +129,8 @@ def _read(path):
def _write(path, data): def _write(path, data):
"""Write YAML helper.""" """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: with open(path, 'w', encoding='utf-8') as outfile:
outfile.write(dump(data)) outfile.write(data)

View File

@ -393,8 +393,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
@ -434,9 +433,10 @@ 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)
yield from asyncio.sleep(0, loop=self.hass.loop)
@asyncio.coroutine @asyncio.coroutine
def async_connect(self): def async_connect(self):
@ -484,9 +484,10 @@ 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)
yield from asyncio.sleep(0, loop=self.hass.loop)
_raise_on_error(result) _raise_on_error(result)
self.progress[mid] = topic self.progress[mid] = topic

View File

@ -2,7 +2,7 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 39 MINOR_VERSION = 39
PATCH_VERSION = '0' PATCH_VERSION = '1'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2) REQUIRED_PYTHON_VER = (3, 4, 2)