Skip to content

Commit

Permalink
Merge tag '1.2.2' into develop
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
vmalloc committed Mar 5, 2018
2 parents 1beb613 + 628054a commit 77f3009
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion logbook/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
15 changes: 5 additions & 10 deletions logbook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,9 @@ def ensure_stream_is_open(self):

class GZIPCompressionHandler(FileHandler):
def __init__(self, filename, encoding=None, level=NOTSET,
format_string=None, delay=False, filter=None, bubble=False,
compression_window_size=4*1024**2, compression_quality=9):
format_string=None, delay=False, filter=None, bubble=False, compression_quality=9):

self._compression_quality = compression_quality
self._compression_window_size = compression_window_size
self._num_unflushed_bytes = 0
super(GZIPCompressionHandler, self).__init__(filename, mode='wb', encoding=encoding, level=level,
format_string=format_string, delay=delay, filter=filter, bubble=bubble)

Expand All @@ -669,14 +667,11 @@ def write(self, item):
item = item.encode(encoding=self.encoding)
self.ensure_stream_is_open()
self.stream.write(item)
self._num_unflushed_bytes += len(item)

def should_flush(self):
return self._num_unflushed_bytes >= self._compression_window_size

def flush(self):
super(GZIPCompressionHandler, self).flush()
self._num_unflushed_bytes = 0
# gzip manages writes independently. Flushing prematurely could mean
# duplicate flushes and thus bloated files
return False


class BrotliCompressionHandler(FileHandler):
Expand Down

0 comments on commit 77f3009

Please sign in to comment.