Skip to content

Add support for Trio via AnyIO #3647

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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open

Conversation

agronholm
Copy link
Contributor

@agronholm agronholm commented May 14, 2025

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

This adds an alternate, AnyIO based asynchronous client. This is necessary in order to make it possible for users of the Trio async framework to use Redis asynchronously. But the potential does not end there. Given that AnyIO supports asyncio as well, it would be possible to later replace the asyncio client with the AnyIO one.

A minor improvement would also be to remove pytest-asyncio from test dependencies and just use the AnyIO test plugin for testing both the AnyIO and asyncio clients.

A few things to note:

  • Given that redis-entraid is a separate library with asyncio-only async code, I had to limit tests involving that to only run on asyncio. I could also migrate that library as follow-up work.
  • This new client must be used with context management due to structured concurrency (task groups being used behind the scenes)
  • If the general idea gets a green light, I will make the necessary documentation changes
  • Further deduplication of code is possible and I am open to it as follow-up work

@agronholm
Copy link
Contributor Author

What is the Python version support policy in this project? I see that v6.0.0 was released with Python 3.8 support even though it reached its end of life last year.

@petyaslavova
Copy link
Collaborator

Hi @agronholm, thank you for your contribution! We will have a look at it soon.
We will discuss the 3.8 support internally and will update you here.

@agronholm
Copy link
Contributor Author

Hi @agronholm, thank you for your contribution! We will have a look at it soon. We will discuss the 3.8 support internally and will update you here.

Any updates on that?

@Graeme22
Copy link

Would love to see this get added!

@agronholm
Copy link
Contributor Author

@petyaslavova It seems like the project has dropped Python 3.8 support, so I've updated my PR accordingly.

Can we establish some communication channel to discuss ways to move forward with this? An important matter is async tests and whether you want to keep using pytest-asyncio or if you'd like all async tests to use anyio instead (allowing you to drop pytest-asyncio as a test dependency). I realize that this PR is a beast to review, but I could sort out the test plugin issue in a separate PR that would be merged first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants