-
Notifications
You must be signed in to change notification settings - Fork 138
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
add @wrapped_async_generator #293
base: master
Are you sure you want to change the base?
Conversation
This still has a task group straddling a |
I'm not an expert on this code (it's based on a prototype by Joshua Oreman), but I think the answer is this:
python-trio/trio#638 (comment) This wrapper absolutely has real world use cases, and the application at my workplace relies on it. |
I would be interested in seeing this use case if you don't mind. If it makes a strong case then I will think about merging this PR. |
The problem and need is clearly stated in the Trio documentation. https://trio.readthedocs.io/en/stable/reference-core.html#cancel-scopes-and-nurseries |
I am quite aware of the problem (as I am currently writing an expansion of the relevant AnyIO documentation) but I am interested in whatever real world uses cases this PR solves, and whether other workarounds could be better. |
It's not hard to imagine cases where you want to use a nursery or cancel scope within an async generator, and people are hitting these cases in real life (we did, and Michael Elsdörfer who filed the trio bug did). The case in our codebase is basically "async generator needs to call out to an external service for each item, and needs to apply a timeout to the individual or aggregate calls". |
Maybe for you it isn't, but I have never written code like that which is why I'm asking to see a real world example. Do I have to ask a third time? |
Hi. I suppose this code would be a solution for my question asked in StackOwerflow here: https://stackoverflow.com/q/70037576/2069071 The example provided there is quite simplified, in reality there are multiple calls to other APIs that provide paginated responses, so the responses are wrapped in async generators. Though, without task groups the responses are currently processed and provided to the user sequentially. CC @agronholm |
TODO: add to documentation
cc: @smurfix