Skip to content

Instantly share code, notes, and snippets.

@loki42
Created June 12, 2012 07:09
Show Gist options
  • Save loki42/2915814 to your computer and use it in GitHub Desktop.
Save loki42/2915814 to your computer and use it in GitHub Desktop.
kazoo (zookeeper) callback with gevent
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