change from coroutine to callback

This commit is contained in:
Pascal Vizeli
2016-10-04 21:29:51 +02:00
parent f57e1fe336
commit 07c709abf4

View File

@@ -146,13 +146,11 @@ class HomeAssistant(object):
# Register the async start # Register the async start
self.loop.create_task(self.async_start()) self.loop.create_task(self.async_start())
@asyncio.coroutine
def stop_homeassistant(*args): def stop_homeassistant(*args):
"""Stop Home Assistant.""" """Stop Home Assistant."""
self.exit_code = 0 self.exit_code = 0
self.async_add_job(self.async_stop) self.async_add_job(self.async_stop)
@asyncio.coroutine
def restart_homeassistant(*args): def restart_homeassistant(*args):
"""Restart Home Assistant.""" """Restart Home Assistant."""
self.exit_code = RESTART_EXIT_CODE self.exit_code = RESTART_EXIT_CODE
@@ -172,13 +170,11 @@ class HomeAssistant(object):
if sys.platform != "win32": if sys.platform != "win32":
self.loop.add_signal_handler( self.loop.add_signal_handler(
signal.SIGTERM, signal.SIGTERM,
asyncio.async, stop_homeassistant
stop_homeassistant()
) )
self.loop.add_signal_handler( self.loop.add_signal_handler(
signal.SIGHUP, signal.SIGHUP,
asyncio.async, restart_homeassistant
restart_homeassistant()
) )
# Run forever and catch keyboard interrupt # Run forever and catch keyboard interrupt
@@ -189,7 +185,7 @@ class HomeAssistant(object):
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
finally: finally:
self.loop.create_task(stop_homeassistant()) self.loop.call_soon(stop_homeassistant)
self.loop.run_forever() self.loop.run_forever()
@asyncio.coroutine @asyncio.coroutine