-
-
Notifications
You must be signed in to change notification settings - Fork 17
[WIP] Use anyio for structured concurrency #294
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
base: master
Are you sure you want to change the base?
Conversation
|
Leaving this PR here for reference as well: redis/redis-py#3647. This looks like a really nice implementation. It would allow us to potentially not break the API at all, since this implementation actually doesn't require the async context manager afaict. |
|
Small update on this! This code is working for me with this PR: from trio import run
from coredis import Redis
redis = Redis.from_url("redis://localhost:6379", decode_responses=True)
async def main():
async with redis:
print(await redis.ping())
async with redis.pubsub(channels=["mychannel"]) as ps:
await redis.publish("mychannel", "test message!")
async for msg in ps:
print(msg)
if msg["type"] == "message":
break
async with redis.pipeline(transaction=False) as pipe:
pipe.incr("tmpkey")
val = pipe.get("tmpkey")
pipe.delete(["tmpkey"])
print(await val)
run(main)
"""
PONG
{'type': 'subscribe', 'pattern': None, 'channel': 'mychannel', 'data': 1}
{'type': 'message', 'pattern': None, 'channel': 'mychannel', 'data': 'test message!'}
1
"""So base functionality is working, and notice I'm using Trio here! |
|
I've also updated the connection pool logic. It works like this: When a client requests a connection from the pool, it gets an existing connection that has less than |
replace sleeps clean up error handling remove futures from basic client update connections to use anyio lazy processing of responses fix edge cases pubsub now working add max idle time small tweaks revert lazy processing, use context managers everywhere pubsub uses strict async context manager update pubsub tests blocking pool working add pipelining and scripting clean up pubsub a bit handle blocking connections for pubsub/pipelines/blocking commands restructure notifications for blocking pool more reliable transactions (from redis-py) tweak connection allocation logic fix race condition remove monitor, small fixes guard connection after close fix on_connect log connection bug add diagnostics for git fix bug catch error add logger idle connections cleanup gracefully, update more tests update more tests, work on sentinel fix sentinel bugs small optimizations Bump sphinxext-opengraph from 0.10.0 to 0.12.0 (alisaifee#293) Bumps [sphinxext-opengraph](https://github.com/sphinx-doc/sphinxext-opengraph) from 0.10.0 to 0.12.0. - [Release notes](https://github.com/sphinx-doc/sphinxext-opengraph/releases) - [Commits](sphinx-doc/sphinxext-opengraph@v0.10.0...v0.12.0) --- updated-dependencies: - dependency-name: sphinxext-opengraph dependency-version: 0.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Ensure ssl_context from kwargs is respected when using from_url factory method Bump sphinxext-opengraph from 0.12.0 to 0.13.0 (alisaifee#297) Bumps [sphinxext-opengraph](https://github.com/sphinx-doc/sphinxext-opengraph) from 0.12.0 to 0.13.0. - [Release notes](https://github.com/sphinx-doc/sphinxext-opengraph/releases) - [Commits](sphinx-doc/sphinxext-opengraph@v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: sphinxext-opengraph dependency-version: 0.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Bump sphinx-sitemap from 2.7.2 to 2.8.0 (alisaifee#296) Bumps [sphinx-sitemap](https://github.com/jdillard/sphinx-sitemap) from 2.7.2 to 2.8.0. - [Release notes](https://github.com/jdillard/sphinx-sitemap/releases) - [Changelog](https://github.com/jdillard/sphinx-sitemap/blob/master/CHANGELOG.rst) - [Commits](jdillard/sphinx-sitemap@v2.7.2...v2.8.0) --- updated-dependencies: - dependency-name: sphinx-sitemap dependency-version: 2.8.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ali-Akber Saifee <[email protected]> Update changelog for 5.1.0 Bump mypy from 1.17.1 to 1.18.1 (alisaifee#299) Bumps [mypy](https://github.com/python/mypy) from 1.17.1 to 1.18.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.17.1...v1.18.1) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.18.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Switch to bitnamilegacy for redis-sentinel Gracefully handle MODULE LIST error (alisaifee#301) PEP-621 compliant project metadata & build configuration (alisaifee#302) - Move all project metadata to pyproject.toml - Use uv build system Fix error in linting step in compatibility workflow Add verbose to pypi upload step Fix pure python build step fix pyproject finish merging
PR Change SummaryIntroduced structured concurrency using anyio, enhancing the async capabilities of the library.
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
Fix merge issues handle errors like EOF improve connection pool Revert "improve connection pool" This reverts commit 99766fd. more robust cxn pool fix txn bug, use bitwise mode instead of flags
update sentinel fix sentinel bugs
sync w/ coredis/anyio
implementation Ensure connection reuse (and restores previous behavior for blocking connection pool).
Use the same ConnectionQueue (LIFO async queue) used by the cluster connection pool for the basic connection pool. This also collapses multiplexed & blocking connections to the same pool thus allowing a single definition of max_connections
If a connection is terminated after being established EndOfStream or ClosedResource errors should mark the connection as unusable and thus discarded by the pool
Description
Begins adding structured concurrency via anyio, a new dependency which replaces async_timeout.
Related issue(s)
Fixes #292
API Changes
Pre-merge checklist