Skip to content
RED SAGSkills
hard20 pts · first answer countspythonmodel-serving

State leaking between requests

This helper runs inside a long-lived model server. What do the two calls print?

def add_feature(row, cache={}):
    cache[row['id']] = row['value']
    return len(cache)

print(add_feature({'id': 1, 'value': 5}))
print(add_feature({'id': 2, 'value': 7}))
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions