This works, but if you group your list you save yourself the while loop, avoiding any risks of infinite loops. How about this?

```python
def group_by(iterable, size):
    """Group an iterable into lists that don't exceed the size given.

    >>> group_by([1,2,3,4,5], 2)
    [[1, 2], [3, 4], [5]]

    """
    sublist = []
    
    for index, item in enumerate(iterable):
        if index > 0 and index % size == 0:
            yield sublist
            sublist = []

        sublist.append(item)

    if sublist:
        yield sublist

# ... later
for batch in group_by(input_iter, batch_size):
    for item in batch:
        self.put(item)

    time.sleep(delay_in_seconds)
    # ... etc
```