Async cleanup part 3 (#4302)
parent
231ef40f53
commit
2e0c185740
|
@ -35,7 +35,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||
"""Setup a FFmpeg Camera."""
|
||||
if not async_run_test(hass, config.get(CONF_INPUT)):
|
||||
return
|
||||
hass.loop.create_task(async_add_devices([FFmpegCamera(hass, config)]))
|
||||
yield from async_add_devices([FFmpegCamera(hass, config)])
|
||||
|
||||
|
||||
class FFmpegCamera(Camera):
|
||||
|
@ -85,7 +85,7 @@ class FFmpegCamera(Camera):
|
|||
break
|
||||
response.write(data)
|
||||
finally:
|
||||
self.hass.loop.create_task(stream.close())
|
||||
self.hass.async_add_job(stream.close())
|
||||
yield from response.write_eof()
|
||||
|
||||
@property
|
||||
|
|
|
@ -43,7 +43,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
# pylint: disable=unused-argument
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Setup a generic IP Camera."""
|
||||
hass.loop.create_task(async_add_devices([GenericCamera(hass, config)]))
|
||||
yield from async_add_devices([GenericCamera(hass, config)])
|
||||
|
||||
|
||||
class GenericCamera(Camera):
|
||||
|
|
|
@ -43,7 +43,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
# pylint: disable=unused-argument
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Setup a MJPEG IP Camera."""
|
||||
hass.loop.create_task(async_add_devices([MjpegCamera(hass, config)]))
|
||||
yield from async_add_devices([MjpegCamera(hass, config)])
|
||||
|
||||
|
||||
def extract_image_from_mjpeg(stream):
|
||||
|
@ -122,7 +122,7 @@ class MjpegCamera(Camera):
|
|||
break
|
||||
response.write(data)
|
||||
finally:
|
||||
self.hass.loop.create_task(stream.release())
|
||||
self.hass.async_add_job(stream.release())
|
||||
yield from response.write_eof()
|
||||
|
||||
@property
|
||||
|
|
|
@ -147,7 +147,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||
devices.append(device)
|
||||
|
||||
yield from asyncio.wait(tasks, loop=hass.loop)
|
||||
hass.loop.create_task(async_add_devices(devices))
|
||||
yield from async_add_devices(devices)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -280,7 +280,7 @@ class SynologyCamera(Camera):
|
|||
break
|
||||
response.write(data)
|
||||
finally:
|
||||
self.hass.loop.create_task(stream.release())
|
||||
self.hass.async_add_job(stream.release())
|
||||
yield from response.write_eof()
|
||||
|
||||
@property
|
||||
|
|
|
@ -47,7 +47,7 @@ class LiteJetLight(Light):
|
|||
def _on_load_changed(self):
|
||||
"""Called on a LiteJet thread when a load's state changes."""
|
||||
_LOGGER.debug("Updating due to notification for %s", self._name)
|
||||
self._hass.loop.create_task(self.async_update_ha_state(True))
|
||||
self._hass.async_add_job(self.async_update_ha_state(True))
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -55,8 +55,7 @@ def async_create(hass, message, title=None, notification_id=None):
|
|||
] if value is not None
|
||||
}
|
||||
|
||||
hass.loop.create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_CREATE, data))
|
||||
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_CREATE, data))
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
|
@ -146,4 +146,4 @@ class TorqueSensor(Entity):
|
|||
def async_on_update(self, value):
|
||||
"""Receive an update."""
|
||||
self._state = value
|
||||
self.hass.loop.create_task(self.async_update_ha_state())
|
||||
self.hass.async_add_job(self.async_update_ha_state())
|
||||
|
|
|
@ -154,7 +154,7 @@ class YrData(object):
|
|||
try_again('{} returned {}'.format(self._url, resp.status))
|
||||
return
|
||||
text = yield from resp.text()
|
||||
self.hass.loop.create_task(resp.release())
|
||||
self.hass.async_add_job(resp.release())
|
||||
except asyncio.TimeoutError as err:
|
||||
try_again(err)
|
||||
return
|
||||
|
|
|
@ -47,12 +47,12 @@ class LiteJetSwitch(SwitchDevice):
|
|||
def _on_switch_pressed(self):
|
||||
_LOGGER.debug("Updating pressed for %s", self._name)
|
||||
self._state = True
|
||||
self._hass.loop.create_task(self.async_update_ha_state())
|
||||
self._hass.async_add_job(self.async_update_ha_state())
|
||||
|
||||
def _on_switch_released(self):
|
||||
_LOGGER.debug("Updating released for %s", self._name)
|
||||
self._state = False
|
||||
self._hass.loop.create_task(self.async_update_ha_state())
|
||||
self._hass.async_add_job(self.async_update_ha_state())
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -119,7 +119,7 @@ class NetioApiView(HomeAssistantView):
|
|||
ndev.start_dates = start_dates
|
||||
|
||||
for dev in DEVICES[host].entities:
|
||||
self.hass.loop.create_task(dev.async_update_ha_state())
|
||||
self.hass.async_add_job(dev.async_update_ha_state())
|
||||
|
||||
return self.json(True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue