'Flush any queued up data in the write buffer and ensure the
compression buffer is flushed out to the underlying transport'

def flush(self):

    wout = self.__wbuf.getvalue()
    if (len(wout) > 0):
        zbuf = self._zcomp_write.compress(wout)
        self.bytes_out += len(wout)
        self.bytes_out_comp += len(zbuf)
    else:
        zbuf = ''
    ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH)
    self.bytes_out_comp += len(ztail)
    if ((len(zbuf) + len(ztail)) > 0):
        self.__wbuf = StringIO()
        self.__trans.write((zbuf + ztail))
    self.__trans.flush()
