code: def next_block(self):
          
  
          assert self.pos <= self.input_len
          if self.pos == self.input_len:
              return None
  
          # Overshoot
          i = self.START_OVERSHOOT
  
          while True:
              try_size = int(self.bs * i)
              size = self.check_request_size(try_size)
              c, d = self.compress_next_chunk(size)
  
              if size != try_size:
                  break
  
              if len(d) < self.bs:
                  i += self.OVERSHOOT_INCREASE
              else:
                  break
  
          # Reduce by one byte until we hit the target
          while True:
  
              if len(d) <= self.bs:
  
                  self.c = c
                  # self.c = self.factory()
                  crc32 = zlib.crc32(self.get_input(size), 0xffffffff) & 0xffffffff
                  self.pos += size
                  self.compressed_bytes += len(d)
                  return crc32, size, d
  
              size -= 1
  
              if size == 0:
                  return None
  
              c, d = self.compress_next_chunk(size)
docs: This could probably be improved; at the moment it starts by trying to overshoot the
          desired compressed block size, then it reduces the input bytes one by one until it
          has met the required block size