From 0ecd185f0df27c33f8987c623b5b1a18a6a9a7c1 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 29 Dec 2016 17:27:58 +0100 Subject: [PATCH] Bugfix close async log handler (#5086) --- homeassistant/util/logging.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/homeassistant/util/logging.py b/homeassistant/util/logging.py index 736fee0d1b3..095e906efe1 100644 --- a/homeassistant/util/logging.py +++ b/homeassistant/util/logging.py @@ -55,18 +55,11 @@ class AsyncHandler(object): When blocking=True, will wait till closed. """ - if not self._thread.is_alive(): - return yield from self._queue.put(None) if blocking: - # Python 3.4.4+ - # pylint: disable=no-member - if hasattr(self._queue, 'join'): - yield from self._queue.join() - else: - while not self._queue.empty(): - yield from asyncio.sleep(0, loop=self.loop) + while self._thread.is_alive(): + yield from asyncio.sleep(0, loop=self.loop) def emit(self, record): """Process a record.""" @@ -85,23 +78,15 @@ class AsyncHandler(object): def _process(self): """Process log in a thread.""" - support_join = hasattr(self._queue, 'task_done') - while True: record = run_coroutine_threadsafe( self._queue.get(), self.loop).result() - # pylint: disable=no-member - if record is None: self.handler.close() - if support_join: - self.loop.call_soon_threadsafe(self._queue.task_done) return self.handler.emit(record) - if support_join: - self.loop.call_soon_threadsafe(self._queue.task_done) def createLock(self): """Ignore lock stuff."""