Skip to content

Commit

Permalink
add logger for kazoo.handlers.threading
Browse files Browse the repository at this point in the history
  • Loading branch information
zqfan committed Jul 21, 2023
1 parent 92bd0c2 commit 1f2b55a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kazoo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __init__(
self.logger = logger or log

# Record the handler strategy used
self.handler = handler if handler else SequentialThreadingHandler()
self.handler = handler or SequentialThreadingHandler(logger=self.logger)
if inspect.isclass(self.handler):
raise ConfigurationError(
"Handler must be an instance of a class, "
Expand Down
5 changes: 3 additions & 2 deletions kazoo/handlers/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ class SequentialThreadingHandler(object):
queue_impl = queue.Queue
queue_empty = queue.Empty

def __init__(self):
def __init__(self, logger=None):
"""Create a :class:`SequentialThreadingHandler` instance"""
self.logger = logger or log
self.callback_queue = self.queue_impl()
self.completion_queue = self.queue_impl()
self._running = False
Expand All @@ -118,7 +119,7 @@ def _thread_worker(): # pragma: nocover
break
func()
except Exception:
log.exception("Exception in worker queue thread")
self.logger.exception("Exception in worker queue thread")
finally:
work_queue.task_done()
del func # release before possible idle
Expand Down

0 comments on commit 1f2b55a

Please sign in to comment.