[Zodb-checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.106.4.4

Jeremy Hylton jeremy at zope.com
Mon Sep 29 10:44:35 EDT 2003


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv11022

Modified Files:
      Tag: Zope-2_7-branch
	ClientStorage.py 
Log Message:
Add timeout for wait=True, to help debug hangs during test runs.


=== ZODB3/ZEO/ClientStorage.py 1.106.4.3 => 1.106.4.4 ===
--- ZODB3/ZEO/ClientStorage.py:1.106.4.3	Fri Sep 19 15:01:27 2003
+++ ZODB3/ZEO/ClientStorage.py	Mon Sep 29 10:44:34 2003
@@ -99,7 +99,7 @@
                  name='', client=None, debug=0, var=None,
                  min_disconnect_poll=5, max_disconnect_poll=300,
                  wait_for_server_on_startup=None, # deprecated alias for wait
-                 wait=None, # defaults to 1
+                 wait=None, wait_timeout=None,
                  read_only=0, read_only_fallback=0,
                  username='', password='', realm=None):
         """ClientStorage constructor.
@@ -152,6 +152,9 @@
         wait -- A flag indicating whether to wait until a connection
             with a server is made, defaulting to true.
 
+        wait_timeout -- Maximum time to wait for a connection before
+            giving up.  Only meaningful if wait is True.
+
         read_only -- A flag indicating whether this should be a
             read-only storage, defaulting to false (i.e. writing is
             allowed by default).
@@ -302,7 +305,7 @@
                                                     tmax=max_disconnect_poll)
 
         if wait:
-            self._wait()
+            self._wait(wait_timeout)
         else:
             # attempt_connect() will make an attempt that doesn't block
             # "too long," for a very vague notion of too long.  If that
@@ -313,7 +316,9 @@
             if not self._ready.isSet():
                 self._cache.open()
 
-    def _wait(self):
+    def _wait(self, timeout):
+        it timeout is not None:
+            deadline = time.time() + timeout
         # Wait for a connection to be established.
         self._rpc_mgr.connect(sync=1)
         # When a synchronous connect() call returns, there is
@@ -325,6 +330,9 @@
             while 1:
                 self._ready.wait(30)
                 if self._ready.isSet():
+                    break
+                if timeout and time.time() > deadline:
+                    log2(PROBLEM, "Timed out waiting for connection")
                     break
                 log2(INFO, "Waiting for cache verification to finish")
         else:




More information about the Zodb-checkins mailing list