[Checkins] SVN: zc.zk/trunk/src/zc/zk/ Increased the initial time to wait for ZooKeeper connections.
jim
cvs-admin at zope.org
Sat May 5 13:52:07 UTC 2012
Log message for revision 125655:
Increased the initial time to wait for ZooKeeper connections.
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
U zc.zk/trunk/src/zc/zk/tests.py
-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt 2012-05-04 23:47:32 UTC (rev 125654)
+++ zc.zk/trunk/src/zc/zk/README.txt 2012-05-05 13:52:04 UTC (rev 125655)
@@ -1165,7 +1165,7 @@
Change History
==============
-0.7.1 (2012-05-??)
+0.8.0 (2012-05-??)
------------------
- Fixed: ephemeral *sequence* nodes were restablished on session
@@ -1181,6 +1181,8 @@
and properties watch-support code in a way that cause scary both
otherwise harmless log message.
+- Increased the initial time to wait for ZooKeeper connections.
+
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-04 23:47:32 UTC (rev 125654)
+++ zc.zk/trunk/src/zc/zk/__init__.py 2012-05-05 13:52:04 UTC (rev 125655)
@@ -154,6 +154,8 @@
class ZooKeeper(Resolving):
+ initial_connection_wait = 9.0
+
def __init__(self, connection_string="127.0.0.1:2181", session_timeout=None,
wait=False):
self.watches = WatchManager()
@@ -195,7 +197,7 @@
init = lambda : zookeeper.init(connection_string, watch_session)
handle = init()
- connected.wait(1)
+ connected.wait(self.initial_connection_wait)
if not connected.is_set():
if wait:
while not connected.is_set():
Modified: zc.zk/trunk/src/zc/zk/disconnectiontests.py
===================================================================
--- zc.zk/trunk/src/zc/zk/disconnectiontests.py 2012-05-04 23:47:32 UTC (rev 125654)
+++ zc.zk/trunk/src/zc/zk/disconnectiontests.py 2012-05-05 13:52:04 UTC (rev 125655)
@@ -26,10 +26,10 @@
def wait_for_zookeeper():
"""
- Normally, zc.zk.ZooKeeper raises an exception if it can't connect to
- ZooKeeper in a second. Some applications might want to wait, so
- zc.zk.ZooKeeper accepts a wait parameter that causes it to wait for a
- connection.
+ Normally, zc.zk.ZooKeeper raises an exception if it can't connect
+ to ZooKeeper in a short time [#initial_connection_wait]_. Some
+ applications might want to wait, so zc.zk.ZooKeeper accepts a wait
+ parameter that causes it to wait for a connection.
>>> zk = None
>>> import zc.thread
@@ -67,6 +67,9 @@
Yay!
>>> zk.close()
+
+ .. [#initial_connection_wait] The initial wait is configurable,
+ mainly for testing, via zc.zk.ZooKeeper.initial_connection_wait
"""
def session_timeout_with_child_and_data_watchers():
Modified: zc.zk/trunk/src/zc/zk/tests.py
===================================================================
--- zc.zk/trunk/src/zc/zk/tests.py 2012-05-04 23:47:32 UTC (rev 125654)
+++ zc.zk/trunk/src/zc/zk/tests.py 2012-05-05 13:52:04 UTC (rev 125655)
@@ -1525,6 +1525,13 @@
def getfqdn():
return 'socket.getfqdn'
+def disconnectiontestsSetup(test):
+ zc.zk.testing.setUp(test)
+ setupstack.register(
+ test, setattr, zc.zk.ZooKeeper, 'initial_connection_wait',
+ zc.zk.ZooKeeper.initial_connection_wait)
+ zc.zk.ZooKeeper.initial_connection_wait = .1
+
checker = zope.testing.renormalizing.RENormalizing([
(re.compile('pid = \d+'), 'pid = 9999'),
(re.compile("{'pid': \d+}"), 'pid = 9999'),
@@ -1562,7 +1569,7 @@
))
suite.addTest(doctest.DocTestSuite(
'zc.zk.disconnectiontests',
- setUp=zc.zk.testing.setUp, tearDown=zc.zk.testing.tearDown,
+ setUp=disconnectiontestsSetup, tearDown=zc.zk.testing.tearDown,
checker=checker,
))
More information about the checkins
mailing list