Repository navigation
Added task handle support to start() and start_soon() - #1153
Conversation
Co-authored-by: David Brochart <david.brochart@gmail.com>
|
This PR doesn't include changes to |
OTOH, nothing is breaking so it could be left to a follow-up. It will need a new |
|
@gschaffner Can we continue the
As for asyncio:
AnyIO, on
AnyIO, on this branch:
Given all this, I think it would be reasonable for us to support |
|
That sounds good to me. |
Co-authored-by: Ganden Schaffner <gschaffner@pm.me>
|
Ok, so let's see where this leaves us. IIRC, you still had some comments left to be addressed:
Was there anything else? |
Yes, I think so. Currently, for the line Similarly, for the
Not much, just a few minor follow-up questions:
|
for more information, see https://pre-commit.ci
|
@gschaffner I think I've addressed your feedback now. LMK if I missed something. |
|
Nice catch of the
Those couple comments should (hopefully) be my final round of feedback for this PR. Everything else looks good to me! |
|
Oop—one more follow-up. Regarding
You changed |
No, I had planned to change that too, depending on the outcome of these discussions, but then it slipped my mind. Will fix. |
Oh, but that hit a snag as this test specifically tests for |
I checked, and |
|
I added |
…tine-compatible object
|
I removed the coro check in |
|
This time I think I covered everything! |
There was a problem hiding this comment.
You changed
from_thread.run/AsyncBackend.run_async_from_threadtoCoroutine(ef4a724), but did not changeanyio.run/AsyncBackend.runtoCoroutine. Was leavinganyio.run/AsyncBackend.runusingAwaitableintentional?No, I had planned to change that too, depending on the outcome of these discussions, but then it slipped my mind. Will fix.
Oh, but that hit a snag as this test specifically tests for
Awaitablesupport. And on Python 3.14+,asyncio.run()also supports arbitrary awaitables.I checked, and
anyio.run()supports arbitrary awaitables on asyncio, but not on Trio. Not sure what we should do about this. But I'll leave the annotations asAwaitablefor now.
Hm, I forgot about that that test. I suppose some options would be:
-
Coroutine[Any, Any, T_Retval] | asyncio.Future[T_Retval]. This annotation would be a lie on Trio, but claiming thatasyncio.Futureis supported on Trio is a smaller and more specific lie than claiming thatAwaitableis supported on Trio. -
Awaitable[T_Retval], and add a wrapper on Trio for runtime support. E.g. https://github.com/agronholm/anyio/pull/567/files#diff-e1aac084a4f60987583d52a647503683759126d41fcd77ae51ea405f278f03b8R73-R94 -
Awaitable[T_Retval], but not supported at runtime (on Trio)
It would be nice to resolve anyio.run's Awaitable situation in the same release (and combined changelog entry) as the other handful of APIs that have been changed back to Coroutine. I think that it isn't a blocker for this PR, however.
LGTM!
|
Thanks for sticking with me! |
NOTE Erasing or replacing the contents of this template will result in your pull
request being summarily closed without consideration!
Changes
Adds
TaskHandlesupport toTaskGroup.start_soon()andTaskGroup.start()as per the group consensus.The latter method has a feature flag for this to preserve backwards compatibility.
Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchdocs/), in case of behavior changes or newfeatures
docs/versionhistory.rst).If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.
Updating the changelog
If there are no entries after the last release, use
**UNRELEASED**as the version.If, say, your patch fixes issue #123, the entry should look like this:
If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.