Browse Source

Added alternative way to limit max number of logs when running in pypy since sys.getsizeof raises TypeError.

opensearch
Ruda Porto Filgueiras 6 years ago
parent
commit
97eabc1137
2 changed files with 7 additions and 2 deletions
  1. +1
    -1
      .travis.yml
  2. +6
    -1
      logzio/sender.py

+ 1
- 1
.travis.yml View File

@ -17,7 +17,7 @@ matrix:
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: pypy2.7
- python: pypy
env: TOXENV=pypy
- python: pypy3.5
env: TOXENV=pypy3


+ 6
- 1
logzio/sender.py View File

@ -156,7 +156,12 @@ class LogzioSender:
current_size = 0
while not self.queue.empty():
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)
if current_size >= MAX_BULK_SIZE_IN_BYTES:
break


Loading…
Cancel
Save