python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 386 forks source link

refactor: Use native Lock timeout instead of reimplementing #676

Closed a-ungurianu closed 1 year ago

a-ungurianu commented 1 year ago

Fixes #605

Why is this needed?

Not needed per se, but removes unnecessary complexity from the lock acquiring code

Proposed Changes

Does this PR introduce any breaking change?

Nope

codecov-commenter commented 1 year ago

Codecov Report

Base: 94.38% // Head: 94.40% // Increases project coverage by +0.02% :tada:

Coverage data is based on head (e978bd7) compared to base (a43ef2b). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #676 +/- ## ========================================== + Coverage 94.38% 94.40% +0.02% ========================================== Files 57 57 Lines 8399 8389 -10 ========================================== - Hits 7927 7920 -7 + Misses 472 469 -3 ``` | [Impacted Files](https://codecov.io/gh/python-zk/kazoo/pull/676?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk) | Coverage Δ | | |---|---|---| | [kazoo/recipe/lock.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vcmVjaXBlL2xvY2sucHk=) | `98.94% <100.00%> (+0.98%)` | :arrow_up: | | [kazoo/handlers/eventlet.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vaGFuZGxlcnMvZXZlbnRsZXQucHk=) | `99.01% <0.00%> (-0.99%)` | :arrow_down: | | [kazoo/protocol/connection.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vcHJvdG9jb2wvY29ubmVjdGlvbi5weQ==) | `96.28% <0.00%> (-0.21%)` | :arrow_down: | | [kazoo/tests/test\_client.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vdGVzdHMvdGVzdF9jbGllbnQucHk=) | `98.70% <0.00%> (-0.20%)` | :arrow_down: | | [kazoo/client.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vY2xpZW50LnB5) | `98.56% <0.00%> (+0.31%)` | :arrow_up: | | [kazoo/handlers/utils.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vaGFuZGxlcnMvdXRpbHMucHk=) | `95.49% <0.00%> (+0.45%)` | :arrow_up: | | [kazoo/handlers/gevent.py](https://codecov.io/gh/python-zk/kazoo/pull/676/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk#diff-a2F6b28vaGFuZGxlcnMvZ2V2ZW50LnB5) | `94.62% <0.00%> (+1.07%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-zk)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

a-ungurianu commented 1 year ago

The test that's failing seems to suggest it's already flaky to begin with. Not sure how my change could affect that specific test. It seems that the client is failing to connect to all zookeeper instances, not just the ones we stopped.

StephenSorriaux commented 1 year ago

Hey, thank you for this. Yes the tests around the "read only" feature is kind of flaky, mostly because one testcase is stopping the cluster. I have a hard time reproducing it locally so yeah...

ceache commented 1 year ago

LGTM Thanks a lot for this.

a-ungurianu commented 1 year ago

My pleasure. I'm trying to learn more about Zookeeper and the Kazoo recipes. Happy give back :)

ceache commented 1 year ago

Sure. Sounds good to me 👍

On Fri, Oct 28, 2022, 13:48 Alex Ungurianu @.***> wrote:

@.**** commented on this pull request.

In kazoo/recipe/lock.py https://github.com/python-zk/kazoo/pull/676#discussion_r1008309882:

@@ -134,7 +134,7 @@ def init(self, client, path, identifier=None, extra_lock_patterns=()): self._retry = KazooRetry( max_tries=None, sleep_func=client.handler.sleep_func )

  • self._lock = client.handler.lock_object()
  • self._thread_lock = client.handler.lock_object()

Actually, how about "_acquire_method_lock" which describes what it does instead of what it is.

— Reply to this email directly, view it on GitHub https://github.com/python-zk/kazoo/pull/676#discussion_r1008309882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIFTHWLOCZH73SPQBTQY7DWFQGWNANCNFSM6AAAAAARMOOKSY . You are receiving this because your review was requested.Message ID: @.***>