def fetch(self, mode, filename, value, read): """ Override from base class diskcache.Disk. Chunking is due to needing to work on pythons < 2.7.13: - Issue #27130: In the "zlib" module, fix handling of large buffers (typically 2 or 4 GiB). Previously, inputs were limited to 2 GiB, and compression and decompression operations did not properly handle results of 2 or 4 GiB. :param int mode: value mode raw, binary, text, or pickle :param str filename: filename of corresponding value :param value: database value :param bool read: when True, return an open file handle :return: corresponding Python value """ value = super(GzipDisk, self).fetch(mode, filename, value, read) if mode == MODE_BINARY: str_io = BytesIO(value) gz_file = gzip.GzipFile(mode='rb', fileobj=str_io) read_csio = BytesIO() while True: uncompressed_data = gz_file.read(2**30) if uncompressed_data: read_csio.write(uncompressed_data) else: break value = read_csio.getvalue() return value
def fetch(self, mode, filename, value, read): value = super(GzipDisk, self).fetch(mode, filename, value, read) if mode == MODE_BINARY: str_io = BytesIO(value) gz_file = gzip.GzipFile(mode='rb', fileobj=str_io) read_csio = BytesIO() while True: uncompressed_data = gz_file.read(2**30) if uncompressed_data: read_csio.write(uncompressed_data) else: break value = read_csio.getvalue() return value