Skip to content
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

Support for aioredis #55

Open
thearchitector opened this issue Jul 20, 2021 · 5 comments
Open

Support for aioredis #55

thearchitector opened this issue Jul 20, 2021 · 5 comments

Comments

@thearchitector
Copy link
Collaborator

Since FastAPI and Starlette are ASGI and are built on asyncio, it would be nice for slowapi to support aioredis as a storage backend. I imagine that it might require some playing around with the limits library, but would be a cool feature.

@thearchitector thearchitector changed the title support for aioredis Support for aioredis Jul 20, 2021
@laurentS
Copy link
Owner

@thearchitector thanks for opening this issue. I think it relates to #3
What you're suggesting makes complete sense in my mind, I initially wanted to make slowapi fully async, just haven't found the time to do so. There's a PR on limits that I opened a while back to make it support async code, and I believe converting the slowapi code to async wouldn't be a huge endeavour.
If you feel like you can help with this, please don't hesitate!

@thearchitector
Copy link
Collaborator Author

@laurentS cool! if you cannot manage to get your PR merged, and its been a year so that might not be likely, another option would just be to just include that custom storage backend here or via a different package?

@thearchitector
Copy link
Collaborator Author

thearchitector commented Jul 23, 2021

@laurentS hey, i threw together a draft PR for migrating the library over to async/await. Obviously limits is still blocking, but its wrapped in a threaded executor so it doesn't block the event loop (same style as starlette).

there's a note about the decorator wrapper that may be a bit contentious, so let me know what you think. in the future, hopefully whenever limits implements your PR, the threaded call to limits can be changed to be conditional on the storage backend used.

@10ourto
Copy link

10ourto commented Aug 15, 2022

@laurentS @thearchitector what is the current status?

@10ourto
Copy link

10ourto commented Aug 15, 2022

I've bumped version of limits up to 2.1 and have tried to use async+redis://localhost:6379/0 with limits[async-redis] extension, but seems it doesn't work out of the box
Error relates to this assertion
image

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

No branches or pull requests

3 participants