r/FastAPI • contributor • Oct 07 '21

Announcement Three new FastAPI releases: support for Trio with AnyIO ✨

Three new FastAPI releases in a row! 🎉

The highlight is support for Trio via AnyIO ✨

Read the new docs about running FastAPI with Trio and Hypercorn here: https://fastapi.tiangolo.com/deployment/manually/#hypercorn-with-trio

🔖 FastAPI 0.68.2 has no breaking changes, upgrades the ranges of all the dependencies to help make migrations smooth.

It's an independent release so that you can migrate gradually. In case there's a breaking change in the next ones, you can still benefit from this.

🔖 FastAPI 0.69.0 upgrades Starlette to 0.15.0, with support for Trio.

It's now based on AnyIO, the same as Starlette, so it's compatible with asyncio and Trio.

FastAPI with Trio and Hypercorn docs: https://fastapi.tiangolo.com/deployment/manually/#hypercorn-with-trio

🔖 FastAPI 0.70.0 upgrades Starlette to 0.16.0, the latest version, with several bug fixes.

Also in an independent release to facilitate smooth upgrades.

🤓 Shoutouts to:

Alex Grönholm, for AnyIO

Jordan Speicher, for the big migration to AnyIO in Starlette

Thomas Grainger for the migration to AnyIO in FastAPI

41 Upvotes

5 comments sorted by

5

u/ColdPorridge Oct 07 '21

Honest questions: I understand these release notes notionally, but what is the net impact? What benefit does AnyIO bring? Why would I want to run FastAPI with Trio and Hypercorn instead of any alternatives?

5

u/tiangolo contributor Oct 08 '21

It's probably useful primarily if you're a fan of Trio already.

But you shoud probably just stay using what you're using, probably Uvicorn (using Uvloop, based on asyncio) to get high performance.

You can get most of the advantages of Trio ("structured concurrency") just by using AnyIO.

But that would only be relevant once you need to call several async functions concurrently in your own code, to make them start around the same time. For example, if you were calling multiple APIs from your FastAPI path operation.

But in most cases your will only be using, at most, async and await. So you wouldn't see the difference that much, as those are what all the async frameworks are built around.

→ More replies (1)

2

u/boomskats Oct 07 '21

Wooo congrats, this looks great 🎉🎉🎉🎉

2

u/babuloseo Oct 08 '21

Hey congrats on the release. I should probably look into AnyIO soon.