In brief
bz2.BZ2Compressor accepts chunks through compress(), while flush() finishes the stream and returns remaining output. The complete file need not be supplied at once.
Useful to know
bz2.BZ2Compressor accepts chunks through compress(), while flush() finishes the stream and returns remaining output. The complete file need not be supplied at once. [1]
Empty intermediate output does not necessarily mean data was lost: the compressor can buffer it. Preserve the call sequence and finishing step. Compression does not add confidentiality; a recipient can restore the contents without a secret key.
Sources
For further detail and to check the information: