Skip to content

Accept one shot iterables in Client.get_many and gets_many - #668

Open
sebxt wants to merge 1 commit into
pinterest:masterfrom
sebxt:fix/get-many-one-shot-iterable
Open

sebxt wants to merge 1 commit into
pinterest:masterfrom
sebxt:fix/get-many-one-shot-iterable

Conversation

@sebxt

@sebxt sebxt commented Oct 20, 2026

Copy link
Copy Markdown

get_many and gets_many are typed as taking Iterable[Key], but _fetch_cmd iterates the keys twice. With a generator the second pass sees nothing, so any hit raised KeyError (or, with ignore_exc=True, the call silently returned {}), and an empty generator sent a bare get command that the server rejects.

This converts keys to a list at the top of get_many and gets_many, before the emptiness check. PooledClient delegates to these methods and is fixed as well.

Tests: added TestClient tests for get_many and gets_many with a generator and with an empty iterator. The full unit and integration suite passes.

Fixes #667

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@sebxt
sebxt requested review from a team and jparise as code owners October 20, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client.get_many and gets_many fail when keys is a generator

1 participant