Explore Library
Code QuizAdvanced

Batching Inference Requests

Find why this batch buffer grows forever and reprocesses old inputs.

Codepython
BATCH_SIZE = 8
buffer = []

def handle(x):
    buffer.append(x)
    if len(buffer) >= BATCH_SIZE:
        results = model.predict(buffer)
        return results
    return None

What is the bug in this request-batching code?