Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 09A0B10430 for ; Tue, 19 Nov 2013 17:34:24 +0000 (UTC) Received: (qmail 62325 invoked by uid 500); 19 Nov 2013 17:34:22 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 61967 invoked by uid 500); 19 Nov 2013 17:34:17 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 61953 invoked by uid 99); 19 Nov 2013 17:34:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Nov 2013 17:34:15 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of comptechgeeky@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-we0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Nov 2013 17:34:09 +0000 Received: by mail-we0-f171.google.com with SMTP id q58so2300283wes.30 for ; Tue, 19 Nov 2013 09:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5HGTkGNe43oPtnb7aX6WW6X534iSbJGmjqokUDPJbg8=; b=MlEsuJZjaEObhKoJYDk/RGs8iYVVxBEM0XINfFfL5rjbFASFwupGqIF+XX+3Fu4jAv lHBgxuQ1uTWp38hOBkQ/SNCtJRT4prNhKVISlCUoQcS7jitpmlbkeqTLiB4w/wWT9Xp9 p+U4YiDHJC96I4bYk21EMBZ5uBssdanWzeIaICQ1QlfTuFBk1QRPh32533fExcSzIz7J EM4AtBeIZENDJ949z4DGF7ZdnzzQuqFUWkQCo1Lt9VLN/JWL7FgMaUlTGD+1WNgd71Bp tZWaMnP8+Bz5qdg/2t4AR7ULpNfUR7TAaTw29EEJ66AvPa3dyMvtYW7211Pula3B5q8X A/VQ== X-Received: by 10.180.184.112 with SMTP id et16mr22198218wic.4.1384882428478; Tue, 19 Nov 2013 09:33:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.106.226 with HTTP; Tue, 19 Nov 2013 09:33:28 -0800 (PST) In-Reply-To: References: From: Techy Teck Date: Tue, 19 Nov 2013 09:33:28 -0800 Message-ID: Subject: Re: How to watch for events on the descendant nodes in ZooKeeper using kazoo? To: user Content-Type: multipart/alternative; boundary=001a11c2269a348ccf04eb8b117c X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2269a348ccf04eb8b117c Content-Type: text/plain; charset=ISO-8859-1 Can anyone help me with this? I am stuck on this problem.. Or if there any better python client for Zookeeper then please let me know as well? On Mon, Nov 18, 2013 at 9:41 PM, Techy Teck wrote: > I recently started working with Python for Zookeeper. I am using `kazoo` > library for Zookeeper. I need to keep a watch on my root node which is - > > /my/example > > couple of other nodes which might get added to my above root node will be > like this - > > /my/example/workflow > /my/example/workflow/v1 > /my/example/workflow/v1/step1 > /my/example/workflow/v1/step2 > > > Now I need to check whether the children which got added in root node > `/my/example` is `/my/example/workflow` or not. If `workflow` node gets > added up in `/my/example` then I will keep a watch on > `/my/example/workflow` node only and if any new children gets added up in > `/my/example/workflow` node then I need to keep a watch on that node as > well. > > Let's say, children of `/my/example/workflow` is > `/my/example/workflow/v1`, so now I need to keep a watch on > `/my/example/workflow/v1` and then if any new nodes gets added up on this > node `/my/example/workflow/v1` such as `/my/example/workflow/v1/step1` and > `/my/example/workflow/v1/step2` then I need to print the children of > `/my/example/workflow/v1` node and I won't make any new watches now. > > Now I am not sure how to keep on calling watches on my children until > certain point, here in this case till `/my/example/workflow/v1` I need to > keep on watching and as soon as all the steps nodes gets added up, I need > to print the children of `/my/example/workflow/v1`. Below is my code which > works fine for watching on only one root node and now I am not sure how to > do my above problem? > > > #!/usr/bin/python > from kazoo.client import KazooClient > > zk = KazooClient(hosts='127.0.0.1:2181') > zk.start() > > @zk.ChildrenWatch("/my/example") > def watch_children(children): > print("Children are now: %s" % children) > > > Any help is really appreciated on this. I was following the documentation > by reading the kazoo tutorial from [here]( > http://kazoo.readthedocs.org/en/latest/basic_usage.html#watchers) > --001a11c2269a348ccf04eb8b117c--