这是indexloc提供的服务,不要输入任何密码
Skip to content

Add support for async generators in batch() function. #1

@feluxe

Description

@feluxe

It would be handy if the batch() function could take AsyncGeneratorType.

return await gather(
    *Threads().batch(
        Call(
            my_func,
            kind=item,
        ) async for item in my_async_gen
    )
)

The current workaround is this:

with Threads() as pool:
    futs = [
        pool.call(
            my_func,
            kind=item,
        ) async for item in my_async_gen
    ]

    return await gather(*(f for f in futs))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions