-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Drop BackgroundManager in favor of fork(func1, func2) #603
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
Conversation
|
Nice one! I think we should probably look at using I essentially want to start only using TaskGroups for any We can also be stronger on our wording wrt. |
| # behavior here, and need to arbitrarily decide which exception to raise. | ||
| # We may want to add an 'httpx.MultiError', manually add support | ||
| # for this situation in the asyncio backend, and re-raise | ||
| # an 'httpx.MultiError' from trio's here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can be more direct on our wording here. If MultiError occurs then we semantically only want either one of those two exceptions raised up to the user.
| try: | ||
| await task | ||
| except asyncio.CancelledError: | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll look a bunch nicer with anyio. (Tho we should leave Trio's implementation alone, since they already have a sensible nursery primitive.)
lovelydinosaur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two comments in-place to clarfiy exactly.
This is looking great! 😃
|
Are we okay adding a dependency on anyio for this? We don’t need it — correctly handling errors in the case of 2 coroutines is easy enough, and the current implementation yields the expected behavior. |
|
Yeah, I'm actually pretty okay with it... I'm strongly enough of the camp that There's been talk of introducing a If we stick with that then we know we're properly adhering to the structued concurrency constraints, even in our asyncio implementation. Once we've got some specifc async docs back in again I'd also like to help us lead our users down the structured concurrency path, and have us recommend |
|
If we think that's being overly zealous, then I guess we could stick with a plain asyncio implementation there, but I'd be more comfortable with us leaning on |
|
Let's leave it as an open option. This is looking great as it stands so we'll get this in, the later tweak the comment note on |
|
👍✨ |
Fixes #565
There's a subtle case regarding handling multi-errors (i.e. what happens if
coroutine2raises an exception while we're handling an exception raised bycoroutine2), but I'd suggest handling it in a subsequent PR. I left a comment in the code regarding this.