[Checkins] SVN: zc.zk/trunk/src/zc/zk/ - Fixed: Session events were misshandled by the high-level children

jim cvs-admin at zope.org
Thu May 3 22:46:21 UTC 2012


Log message for revision 125645:
  - Fixed: Session events were misshandled by the high-level children
    and properties watch-support code in a way that cause scary both
    otherwise harmless log message.
  

Changed:
  U   zc.zk/trunk/src/zc/zk/README.txt
  U   zc.zk/trunk/src/zc/zk/__init__.py
  U   zc.zk/trunk/src/zc/zk/disconnectiontests.py

-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt	2012-05-03 21:35:29 UTC (rev 125644)
+++ zc.zk/trunk/src/zc/zk/README.txt	2012-05-03 22:46:17 UTC (rev 125645)
@@ -1177,6 +1177,10 @@
 - Fixed: The testing ZooKeeper mock didn't implement ``exists``
   correctly.
 
+- Fixed: Session events were misshandled by the high-level children
+  and properties watch-support code in a way that cause scary both
+  otherwise harmless log message.
+
 0.7.0 (2012-01-27)
 ------------------
 

Modified: zc.zk/trunk/src/zc/zk/__init__.py
===================================================================
--- zc.zk/trunk/src/zc/zk/__init__.py	2012-05-03 21:35:29 UTC (rev 125644)
+++ zc.zk/trunk/src/zc/zk/__init__.py	2012-05-03 22:46:17 UTC (rev 125645)
@@ -332,6 +332,9 @@
 
         def handler(h, t, state, p, reraise=False):
 
+            if t == zookeeper.SESSION_EVENT:
+                return
+
             if state != zookeeper.CONNECTED_STATE:
                 # This can happen if we get disconnected or a session expires.
                 # When we reconnect, we should restablish the watchers.

Modified: zc.zk/trunk/src/zc/zk/disconnectiontests.py
===================================================================
--- zc.zk/trunk/src/zc/zk/disconnectiontests.py	2012-05-03 21:35:29 UTC (rev 125644)
+++ zc.zk/trunk/src/zc/zk/disconnectiontests.py	2012-05-03 22:46:17 UTC (rev 125645)
@@ -125,11 +125,57 @@
     ['providers', 'x']
 
     >>> print handler
-    zc.zk WARNING
-      Node watcher event -1 with non-connected state, -112
-    zc.zk WARNING
-      Node watcher event -1 with non-connected state, -112
     zc.zk INFO
       connected 0
 
     """
+
+def session_events_are_ignored_by_child_and_data_watch_support():
+    """Session events are send to child, data and exists watcher.
+
+    This should have no impact on the watch support.
+
+    Nothing should get logged. No errors, no warnings.
+
+    >>> zk = zc.zk.ZooKeeper('zookeeper.example.com:2181')
+    >>> handler = zope.testing.loggingsupport.InstalledHandler('zc.zk')
+    >>> @zk.properties('/fooservice')
+    ... def p(data):
+    ...     print 'property changed'
+    property changed
+
+    >>> @zk.children('/fooservice')
+    ... def c(data):
+    ...     print 'children changed'
+    children changed
+
+    >>> node = ZooKeeper._traverse('/fooservice')
+    >>> len(node.watchers), len(node.child_watchers)
+    (1, 1)
+
+    >>> for state in (zookeeper.CONNECTING_STATE,
+    ...               zookeeper.CONNECTED_STATE,
+    ...               zookeeper.EXPIRED_SESSION_STATE,
+    ...     ):
+    ...     for h, w in (node.watchers + node.child_watchers):
+    ...         w(h, zookeeper.SESSION_EVENT, state, '')
+
+    >>> print handler,
+    >>> handler.uninstall()
+
+    >>> len(node.watchers), len(node.child_watchers)
+    (1, 1)
+
+    >>> zk2 = zc.zk.ZooKeeper('zookeeper.example.com:2181')
+    >>> p2 = zk2.properties('/fooservice')
+    >>> p2.update(z=1)
+    property changed
+    >>> _ = zk2.create('/fooservice/xxx', '', zc.zk.OPEN_ACL_UNSAFE)
+    children changed
+
+    >>> len(node.watchers), len(node.child_watchers)
+    (2, 1)
+
+    >>> zk.close()
+    >>> zk2.close()
+    """



More information about the checkins mailing list