zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Loki Davison <loki.davi...@gmail.com>
Subject gevent, python and zookeeper.
Date Fri, 25 May 2012 13:43:58 GMT
Hi all,
I'm attempting to use zookeeper basically as a name server and to a
lesser extent as a lock server. However I'm having trouble getting any
of the python bindings to work with gevent and do what i require. I
first implemented everything using zktools and zc.zk, which looked
well documented and thought out and it all works well with threads but
breaks with gevent. I'm not sure how to implement the solution from
resumelb with monkey patch all (which i need to do for redis). I've
tried to use kazoo but the watches are only fired once. If I attempt
to reregister the watcher in the call back it block and never returns.
I suspect i'm doing something incorrectly with kazoo. Has anyone
successfully used watches with kazoo or can suggest a solution? The
use case in question is a failover connection pool for redis, that
also does leader election (redis has a single master), the code is on
github using zktools:


Kazoo test case:

import kazoo
a = kazoo.KazooClient("localhost:2181")

import kazoo.recipe.party as party
p = party.ZooParty(a, "/redis/providers", "")

def w_b(e):
    print "### watcher called"
    ## a.get_children("/redis/providers", w_b) ## explodes if i try
this, otherwise called once.
    return True

a.get_children("/redis/providers", w_b)


View raw message