Tweak block_till_done (#4245)

This commit is contained in:
Paulus Schoutsen 2016-11-06 08:43:32 -08:00 committed by GitHub
parent 7774a03a55
commit 98f41d6b84

View File

@ -252,8 +252,9 @@ class HomeAssistant(object):
"""Block till all pending work is done."""
while True:
# Wait for the pending tasks are down
if len(self._pending_tasks) > 0:
yield from asyncio.wait(self._pending_tasks, loop=self.loop)
pending = list(self._pending_tasks)
if len(pending) > 0:
yield from asyncio.wait(pending, loop=self.loop)
# Verify the loop is empty
ret = yield from self.loop.run_in_executor(None, self._loop_empty)