take is a reusable asynchronous generator for limiting another asynchronous generator to a requested maximum number of items. It supports fixed-size retrieval while preserving the convenience of an async for loop and avoiding a complete result set in memory. section 5.7.2
Taking the first five products
Wrap a database cursor with take(product_generator, 5), then iterate normally with async for. The generator counts yielded records and stops after the fifth product. section 5.7.2
