-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
anyio integration #1157
anyio integration #1157
Conversation
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
There's a weird bit of code in async with anyio.move_on_after(
0.001
): # XXX: too small of a deadline and this blocks
message = await self._receive() The existing code used EDIT: refactored to an event in 4dd8c5d |
Not really, no. Trio does not do any tricks in that regard. As I understand, starting with Python 3.10 even asyncio doesn't need that. |
03e312e added a chunk of work on EDIT: not a problem anymore |
My recommendation is to base this work on AnyIO 3.0, of which the first RC release is imminent. Since this is a new feature, I don't think backwards compatibility is necessary. |
On that note, the 3.0.0rc1 pre-release is out now. |
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.
These should get you going on AnyIO 3. I had at least one question among the suggestions too.
I've pushed changes to use anyio 3.0.0rc1, thanks @agronholm ! There's some failing tests left:
Those tests seem to not be getting data in There's another test I've had to skip because it blocks forever: test_graphql_async_old_style_executor, need to investigate that one a bit. |
Those test failures don't look too bad. Let me know if you need more help. You can catch me on Gitter. |
else:
# Old style. Use 'executor'.
# We should remove this in the next median/major version bump.
self.executor = executor
self.executor_class = None
self.is_async = isinstance(executor, AsyncioExecutor) The test for this is blocking forever. I'd rather not spend too much effort debugging that, since it's slated to be removed. I will remove it assuming that this PR would bring about a median/major version bump. |
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.
I think it's time 🚀
Cheers @JayH5 and thank you everyone for your help/work on this. I think this is an important step in bringing structured concurrency to the mainstream and I'm grateful for the opportunity to contribute. ❤️ |
Just one question: how soon can we expect to see this in a release? |
@agronholm I think it's all but released now: #1202 |
Fixes: 42592d6 ("anyio integration (encode#1157)")
Fixes: 42592d6 ("anyio integration (encode#1157)")
Fixes: #811
This adds support for
asyncio
andtrio
by leveraging anyio and a little more structured concurrency in spots.Things to do yet:
TestClient
rewritten for anyio, probably with portals.anyio
3.0 releaseThis adds a hard dependency for starlette, which didn't exist before, and was a selling point. In my opinion, the benefit is worth it. It would be great to use starlette with either
uvicorn
orhypercorn
using Trio.This also removes the need for
aiofiles
which is gained for free withanyio
.Some drawbacks are that the other integrations such as graphql are only currently compatible with
asyncio
. But, this does not make those integrations incompatible. It does give users the ability to use trio without them, and maybe they can be ported in the future as well.I created a branch for framework benchmarks here: https://github.com/uSpike/FrameworkBenchmarks/tree/starlette-anyio
See results: https://www.techempower.com/benchmarks/#section=test&shareid=c92a1338-0058-486c-9e47-c92ec4710b6a&hw=ph&test=query&a=2
There is a performance penalty to using anyio. The weighted composite score is 173 vs 165, so a 4.5% drop in performance.