def _bulk_size_generator(num_records, bulk_size, active):
while active and num_records > <NUM_LIT:0>:<EOL><INDENT>req_size = min(num_records, bulk_size)<EOL>num_records -= req_size<EOL>yield req_size<EOL><DEDENT>
Generate bulk_size until num_records is reached or active becomes false

    >>> gen = _bulk_size_generator(155, 50, [True])
    >>> list(gen)
    [50, 50, 50, 5]