python-zk/kazoo — pull request #63 by dougm (2013-03-22 04:05:52+00:00)
Title: Reset watchers on lost connection

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 client.py 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/test_watchers.py", line 507, in test_data_watcher
eq_(len(events), 2)
AssertionError: 3 != 2