Compress a string using gzip.

    :type chunk: str
    :param chunk: The string to be compressed.

    :rtype: str
    :returns: `chunk` compressed.

def inline_compress_chunk(chunk, level=1):
    """Compress a string using gzip.

    :type chunk: str
    :param chunk: The string to be compressed.

    :rtype: str
    :returns: `chunk` compressed.

    """
    b = cStringIO.StringIO()
    g = gzip.GzipFile(fileobj=b, mode='wb', compresslevel=level)
    g.write(chunk)
    g.close()
    cc = b.getvalue()
    b.close()
    return cc