From 5797bad7be90e1173205723f1511d937de3ea9d0 Mon Sep 17 00:00:00 2001 From: Ales Teska Date: Fri, 10 Feb 2023 17:32:54 +0100 Subject: [PATCH] Refactorization in the Zookeeper advertise code. --- asab/zookeeper/container.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/asab/zookeeper/container.py b/asab/zookeeper/container.py index ad9df44ed..7393bee92 100644 --- a/asab/zookeeper/container.py +++ b/asab/zookeeper/container.py @@ -115,7 +115,6 @@ def on_watcher_trigger(): self.App.PubSub.publish(self.App.PubSub.publish("ZooKeeper.watcher!", data, stat)) self.App.Loop.call_soon_threadsafe(on_watcher_trigger) - async def create_watcher(self, client, path): # Do this in executor watcher = kazoo.recipe.watchers.DataWatch(client, path, func=self._on_watcher_trigger) @@ -149,17 +148,8 @@ async def _do_advertise(self, zoocontainer): await zoocontainer.ZooKeeper.set_data(self.Node, self.Data) return - # Parms description - # self.Path. Path to be created - # self.Data. Data in the path - # sequential=True. Path is suffixed with a unique index. - # ephemeral=True. Node created is ephemeral - - async def create(): - self.Node = await zoocontainer.ZooKeeper.create(self.Path, self.Data, True, True) - try: - await create() + self.Node = await zoocontainer.ZooKeeper.create(self.Path, self.Data, sequential=True, ephemeral=True) except kazoo.exceptions.NoNodeError: await zoocontainer.ZooKeeper.ensure_path(self.Path.rstrip(self.Path.split("/")[-1])) - await create() + self.Node = await zoocontainer.ZooKeeper.create(self.Path, self.Data, sequential=True, ephemeral=True)