Skip to content

Commit

Permalink
Remove compression window from Gzip compressed handlers
Browse files Browse the repository at this point in the history
gzip handles the compression level/window to itself
  • Loading branch information
vmalloc committed Mar 5, 2018
1 parent 1beb613 commit f022ebd
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions logbook/handlers.py
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 f022ebd

Please sign in to comment.