I recently started working with Python for Zookeeper
. I am using kazoo
library for Zookeeper.
I have a very simple use case using kazoo for Zookeeper. I have a root node which is - /root
. Now I need to keep a watch on the root node /root
and if the new node which gets added to root node /root
is /root/testing
then I will only keep a watch on the /root/testing
node. I don't want to keep a watch on any other node apart from the testing
node. And then if any new children get added up to the /root/testing
node, then I will keep a watch on them as well.
Let's say the child below that gets added up -
`/root/testing/test1`
Then I will keep a watch on test1
node as well.
Is this possible to do using Kazoo in Zookeeper? I am only able to keep a watch on one Zookeeper node (/root
) with the code below:
#!/usr/bin/python
import time
from kazoo.client import KazooClient
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()
########################################
@zk.ChildrenWatch("/root/testing")
def watch_children(children):
print(children)
########################################
while True:
time.sleep(5)
Can anyone help me with this in making multiple watches on the child node?