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

Implement simple asyncio wrapper API with basic tests #646

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Traktormaster
Copy link

Fixes (or attempts to fix) #185 and #499.

Asyncio interoperability is required for what I'm working on, so I've came up with a simple solution. There is no change to the already existing client or handlers. The asyncio client expands on the base threaded implementation. The completely separate implementation ensures no breaking changes.

Python version support

  • The installed library may work as before. Using the asyncio implementation is optional as it is a separate package, it will not be imported unless explicitly wanted. However the testing will require it to work making Python 2 not supported anymore. (I'd argue that is a good thing)
  • This PR will only work with python 3.7+ in its current state. I'd argue that's also acceptable, 3.6 is nearing its EOL. Though this could be changed to support 3.6 as well.

Further work

The KazooRetry implementation cannot be used with the new asyncio API. I'm on the fence about re-implementing it as using a general solution would likely be fine. If I used https://github.com/kaelzhang/python-aioretry for example, it would impose new dependencies though.

More tests would be nice definitely. However the wrapper API is so simple, that it may actually be unnecessary.

I'm going to use a build of this fork. Depending on my experiences I'll likely push updates here as necessary. However, I'm not sure if I'll have time to make this a complete PR with coverage and extended python version support.

kazoo/aio/client.py Outdated Show resolved Hide resolved
kazoo/aio/client.py Outdated Show resolved Hide resolved
kazoo/aio/client.py Outdated Show resolved Hide resolved
kazoo/aio/client.py Outdated Show resolved Hide resolved
kazoo/aio/client.py Outdated Show resolved Hide resolved
kazoo/aio/handler.py Outdated Show resolved Hide resolved
kazoo/aio/handler.py Outdated Show resolved Hide resolved
kazoo/aio/handler.py Outdated Show resolved Hide resolved
kazoo/aio/handler.py Outdated Show resolved Hide resolved
kazoo/aio/handler.py Outdated Show resolved Hide resolved
kazoo/testing/__init__.py Outdated Show resolved Hide resolved
kazoo/testing/harness.py Outdated Show resolved Hide resolved
kazoo/aio/retry.py Outdated Show resolved Hide resolved
sleep_time = cur_delay * get_jitter()
if (
stop_time is not None
and time.perf_counter() + sleep_time >= stop_time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line break before binary operator

@StephenSorriaux StephenSorriaux mentioned this pull request Mar 3, 2024
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.

None yet

2 participants