Skip to content

Reset watchers on lost connection #63

merged 1 commit into from Apr 28, 2013

2 participants

dougm commented Mar 22, 2013

This likely isn't the correct fix, but found this issue while testing DataWatch.
Against a single zk server, client._data_watchers accumulate with each restart
of the zk server. After restarting the zk server, a DataWatch callback for given
path will be called twice. Restart again, called three times, and so on.

Without the change to reset_watchers, you should see the following:
$ ZOOKEEPER_PATH=$PWD/bin/zookeeper ./bin/nosetests kazoo.tests.test_watchers:KazooDataWatcherRestartTests.test_data_watcher

File "/.../kazoo/kazoo/tests/", line 507, in test_data_watcher
eq_(len(events), 2)
AssertionError: 3 != 2

dougm commented Apr 16, 2013

Any thoughts on this one? Here's a standalone example of the issue:
Against brew installed zookeeper, number of watcher callbacks increases with each server restart:

$ python

kz> Version: 2, data: foo

$ zkCli set /some/path foo

kz> Version: 3, data: foo

$ zkServer restart

kz> Version: 4, data: foo
kz> Version: 4, data: foo

$ zkServer restart
$ zkCli set /some/path foo

kz> Version: 4, data: foo
kz> Version: 4, data: foo
kz> Version: 4, data: foo

Python Zookeeper High-Level Libraries member

Yea, I'm wondering how this was in there so long before it was caught. THANKS!

@bbangert bbangert merged commit 385e632 into python-zk:master Apr 28, 2013

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.