diff options
author | Steffen Neubauer <s.neubauer@syseleven.de> | 2021-11-12 12:33:50 +0100 |
---|---|---|
committer | Steffen Neubauer <s.neubauer@syseleven.de> | 2021-12-02 08:31:30 +0100 |
commit | 569c89cda811593f99294c055d00ebf27aab3068 (patch) | |
tree | 623a73d6ad6d5a7b2d476799b005e322a4f7bc30 | |
parent | 1ea097d5d50466705ca1ec12945ce290c256915c (diff) | |
download | kazoo-569c89cda811593f99294c055d00ebf27aab3068.tar.gz |
fix(recipe): fix deprecation warning from threading.Event
reasoning:
- `is_set` is supported since Python2.6 (https://docs.python.org/2.7/library/threading.html)
- Starting from Python3.5 docs the `isSet` spelling is not even mentioned anymore (https://docs.python.org/3.5/library/threading.html)
- Python3.10 will give a deprecation warning when the `isSet` spelling is used (https://docs.python.org/3.10/library/threading.html)
-rw-r--r-- | kazoo/recipe/lock.py | 4 | ||||
-rw-r--r-- | kazoo/recipe/queue.py | 2 | ||||
-rw-r--r-- | kazoo/testing/harness.py | 4 | ||||
-rw-r--r-- | kazoo/tests/test_lock.py | 8 |
4 files changed, 9 insertions, 9 deletions
diff --git a/kazoo/recipe/lock.py b/kazoo/recipe/lock.py index 7722a97..8bcc236 100644 --- a/kazoo/recipe/lock.py +++ b/kazoo/recipe/lock.py @@ -276,7 +276,7 @@ class Lock(object): pass # predecessor has already been deleted else: self.wake_event.wait(timeout) - if not self.wake_event.isSet(): + if not self.wake_event.is_set(): raise LockTimeout( "Failed to acquire lock on %s after %s seconds" % (self.path, timeout) @@ -638,7 +638,7 @@ class Semaphore(object): # If blocking, wait until self._watch_lease_change() is # called before returning self.wake_event.wait(w.leftover()) - if not self.wake_event.isSet(): + if not self.wake_event.is_set(): raise LockTimeout( "Failed to acquire semaphore on %s" " after %s seconds" % (self.path, timeout) diff --git a/kazoo/recipe/queue.py b/kazoo/recipe/queue.py index 5fd7f89..3887973 100644 --- a/kazoo/recipe/queue.py +++ b/kazoo/recipe/queue.py @@ -292,7 +292,7 @@ class LockingQueue(BaseQueue): if event is not None and event.type != EventType.CHILD: return with lock: - if canceled or flag.isSet(): + if canceled or flag.is_set(): return values = self.client.retry( self.client.get_children, diff --git a/kazoo/testing/harness.py b/kazoo/testing/harness.py index ce8748a..4cd419d 100644 --- a/kazoo/testing/harness.py +++ b/kazoo/testing/harness.py @@ -229,11 +229,11 @@ class KazooTestHarness(unittest.TestCase): self.client._call(break_event, None) lost.wait(5) - if not lost.isSet(): + if not lost.is_set(): raise Exception("Failed to get notified of broken connection.") safe.wait(15) - if not safe.isSet(): + if not safe.is_set(): raise Exception("Failed to see client reconnect.") self.client.retry(self.client.get_async, '/') diff --git a/kazoo/tests/test_lock.py b/kazoo/tests/test_lock.py index 0e16949..edfdb90 100644 --- a/kazoo/tests/test_lock.py +++ b/kazoo/tests/test_lock.py @@ -397,7 +397,7 @@ class KazooLockTests(KazooTestCase): with lock: started.set() event.wait(timeout) - if not event.isSet(): + if not event.is_set(): # Eventually fail to avoid hanging the tests self.fail("lock2 never timed out") @@ -409,7 +409,7 @@ class KazooLockTests(KazooTestCase): client2 = self._get_client() client2.start() started.wait(5) - assert started.isSet() is True + assert started.is_set() is True lock2 = client2.Lock(self.lockpath, "two") try: lock2.acquire(timeout=timeout) @@ -712,7 +712,7 @@ class TestSemaphore(KazooTestCase): with sem: started.set() event.wait(timeout) - if not event.isSet(): + if not event.is_set(): # Eventually fail to avoid hanging the tests self.fail("sem2 never timed out") @@ -724,7 +724,7 @@ class TestSemaphore(KazooTestCase): client2 = self._get_client() client2.start() started.wait(5) - assert started.isSet() is True + assert started.is_set() is True sem2 = client2.Semaphore(self.lockpath, "two") try: sem2.acquire(timeout=timeout) |