def bz2_compress_stream(src, level=<NUM_LIT:9>):
compressor = bz2.BZ2Compressor(level)<EOL>for block in src:<EOL><INDENT>encoded = compressor.compress(block)<EOL>if encoded:<EOL><INDENT>yield encoded<EOL><DEDENT><DEDENT>yield compressor.flush()<EOL>
Compress data from `src`.

    Args:
        src (iterable): iterable that yields blocks of data to compress
        level (int): compression level (1-9) default is 9

    Yields:
        blocks of compressed data