-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow AsyncGenerator or AsyncIterator for "args" #46
Comments
Hi @Ikatono This sounds interesting but I'm having a hard time seeing why wou'd need aiometer to iterate over that async iterator? If you could come up with some example code you'd like to be able to write, or how you would write it with trimeter, that would help clarifying, I think. |
Sure. So here's what my current code looks like:
With trimeter I should be able to write this instead:
Besides saving me from having to chunk my generator, the second keep Looking at trimeter, they convert non-async iterators to async then work through them in an
The equivalent section in aiometer is:
so maybe something along the lines of:
|
Oops, closing was a misclick. Right! Thanks so much for the code samples and investigation. So now it's clearer what needs to be done -- the list argument should be expanded to accept async iterables. "Sync" arguments (list, iterable, etc) should be wrapped in an async iterabke so we can reprogram amap against an async iterabke always. If you're up for giving this a bite I'd be happy to review a PR -even partial- towards this. |
Sure! So the change needs to be applied to |
In short, yes! Perhaps an update of the API reference as well, or some example of using an async iterator. |
Hi @florimondmanca , Can you confirm whether the tests pass for you on 0.5.0? About half the tests are failing for me on WSL, seems like a dependency issue I'm having a hard time tracking down. |
It's very possible that there's a dependency issue, this happens from time to time as transient dependencies may induce some breakage. If you open up a PR against the current state of your code we'll be able to see how that looks like in CI. |
I pulled the repo on a linux machine this time and the tests pass without issue. |
It would be useful to be able start some tasks before all of the arguments are available. This appears to be supported in trimeter, although I haven't tested since the last commit was 4 years ago.
As an example use case, I'm currently trying to consume a paginated API. I have an asynchronous generator that yields the items from a page while pre-loading the next page. As aiometer is right now, (I believe) I need to either generate the whole list of items at first (which requires downloading each page sequentially until I get an empty page), or yield chunks of results and call aiometer.amap on each chunk. It would be cleaner if I could pass the AsyncGenerator directly to amap and have it await items as needed.
The text was updated successfully, but these errors were encountered: