From d41ceabe82c2c459232b68438564817e7d2ef768 Mon Sep 17 00:00:00 2001 From: Jotham Apaloo Date: Tue, 20 Feb 2018 09:14:41 -0800 Subject: [PATCH] Leave initialization in c'tor, just call start() where needed --- logzio/sender.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/logzio/sender.py b/logzio/sender.py index 3a40dd0..8ed7c0d 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -34,9 +34,6 @@ class LogzioSender: # Create a queue to hold logs self.queue = queue.Queue() - self._initialize_sending_thread() - - def _initialize_sending_thread(self): self.sending_thread = Thread(target=self._drain_queue) self.sending_thread.daemon = False self.sending_thread.name = "logzio-sending-thread" @@ -45,7 +42,7 @@ class LogzioSender: def append(self, logs_message): # Queue lib is thread safe, no issue here if not self.sending_thread.is_alive(): - self._initialize_sending_thread() + self.sending_thread.start() self.queue.put(json.dumps(logs_message)) def flush(self):