Browse Source

Deleting objects to make sure garbage collector will release memory.

opensearch
Ruda Porto Filgueiras 6 years ago
parent
commit
f87341d263
2 changed files with 10 additions and 0 deletions
  1. +3
    -0
      logzio/handler.py
  2. +7
    -0
      logzio/sender.py

+ 3
- 0
logzio/handler.py View File

@ -32,6 +32,9 @@ class LogzioHandler(logging.Handler):
backup_logs=backup_logs) backup_logs=backup_logs)
logging.Handler.__init__(self) logging.Handler.__init__(self)
def __del__(self):
del self.logzio_sender
def extra_fields(self, message): def extra_fields(self, message):
not_allowed_keys = ( not_allowed_keys = (


+ 7
- 0
logzio/sender.py View File

@ -48,6 +48,11 @@ class LogzioSender:
self.queue = queue.Queue() self.queue = queue.Queue()
self._initialize_sending_thread() self._initialize_sending_thread()
def __del__(self):
del self.logger
del self.backup_logs
del self.queue
def _initialize_sending_thread(self): def _initialize_sending_thread(self):
self.sending_thread = Thread(target=self._drain_queue) self.sending_thread = Thread(target=self._drain_queue)
self.sending_thread.daemon = False self.sending_thread.daemon = False
@ -153,6 +158,8 @@ class LogzioSender:
'backing up to local file system', number_of_retries) 'backing up to local file system', number_of_retries)
backup_logs(logs_list, self.logger) backup_logs(logs_list, self.logger)
del logs_list
def _get_messages_up_to_max_allowed_size(self): def _get_messages_up_to_max_allowed_size(self):
logs_list = [] logs_list = []
current_size = 0 current_size = 0


Loading…
Cancel
Save