Created
June 12, 2012 07:09
-
-
Save loki42/2915814 to your computer and use it in GitHub Desktop.
kazoo (zookeeper) callback with gevent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import gevent | |
def kazoo_callback(zk, func, event): | |
""" | |
usage example | |
zk.get_children("/redis/providers", partial(kazoo_callback, zk, provider_changed)) | |
""" | |
def watcher(e): | |
print "### watcher called", event | |
func(zk.get_children(event.path, partial(kazoo_callback, zk, func))) | |
gevent.spawn(watcher, event) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment