Skip to content

Add direct async iteration on Dataset and KeyValueStore #1745

@vdusek

Description

@vdusek

Motivation

Crawlee JS recently added async iterator support (PR #3352) allowing direct iteration over storages:

for await (const item of dataset) { ... }
for await (const [key, value] of kvs) { ... }

Python has iterate_items() on Dataset and iterate_keys() on KeyValueStore, but lacks:

  1. __aiter__ protocol on Dataset and KeyValueStore — no async for item in dataset syntax.
  2. iterate_values() / iterate_entries() on KeyValueStore — can only iterate keys, not key-value pairs.

Proposed changes

Dataset

  • Add __aiter__ delegating to iterate_items() so async for item in dataset works.

KeyValueStore

  • Add iterate_values() — yields values.
  • Add iterate_entries() — yields (key, value) tuples.
  • Add __aiter__ delegating to iterate_entries() so async for key, value in kvs works.

JS reference

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions