Browse Source

Merge pull request #33 from rudaporto/master

Add support for `pypy` and `pypy3` interpreter and remove support for python 3.3
opensearch
Ido Halevi 6 years ago
committed by GitHub
parent
commit
a4d23ba996
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions
  1. +4
    -0
      .travis.yml
  2. +3
    -0
      logzio/handler.py
  3. +13
    -1
      logzio/sender.py
  4. +1
    -1
      tox.ini

+ 4
- 0
.travis.yml View File

@ -15,6 +15,10 @@ matrix:
env: TOXENV=py35 env: TOXENV=py35
- python: 3.6 - python: 3.6
env: TOXENV=py36 env: TOXENV=py36
- python: pypy
env: TOXENV=pypy
- python: pypy3.5
env: TOXENV=pypy3
install: install:
- pip install tox - pip install tox


+ 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 = (


+ 13
- 1
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,12 +158,19 @@ 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
while not self.queue.empty(): while not self.queue.empty():
current_log = self.queue.get() current_log = self.queue.get()
current_size += sys.getsizeof(current_log)
try:
current_size += sys.getsizeof(current_log)
except TypeError:
# pypy do not support sys.getsizeof
current_size += len(current_log) * 4
logs_list.append(current_log) logs_list.append(current_log)
if current_size >= MAX_BULK_SIZE_IN_BYTES: if current_size >= MAX_BULK_SIZE_IN_BYTES:
break break


+ 1
- 1
tox.ini View File

@ -1,6 +1,6 @@
[tox] [tox]
minversion = 1.7.2 minversion = 1.7.2
envlist = flake8, py3flake8, py27, py34, py35, py36
envlist = flake8, py3flake8, py27, py34, py35, py36, pypy, pypy3
skip_missing_interpreters = true skip_missing_interpreters = true
[testenv] [testenv]


Loading…
Cancel
Save