[Zope-Checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.94

Jeremy Hylton jeremy@zope.com
Tue, 29 Apr 2003 15:43:15 -0400


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

Modified Files:
	ClientStorage.py 
Log Message:
Drive asyncore during cache verification in synchronous mode.

If asyncore is not running in a separate thread, the client needs to
call poll() to perform the IO necessary for cache verification to
finish.

This allows us to eliminate several calls to sync() in the test suite.


=== ZODB3/ZEO/ClientStorage.py 1.93 => 1.94 ===
--- ZODB3/ZEO/ClientStorage.py:1.93	Tue Apr 22 14:00:16 2003
+++ ZODB3/ZEO/ClientStorage.py	Tue Apr 29 15:42:44 2003
@@ -293,18 +293,21 @@
                     break
                 log2(INFO, "Wait for cache verification to finish")
         else:
-            # If there is no mainloop running, this code needs
-            # to call poll() to cause asyncore to handle events.
-            while 1:
-                if self._ready.isSet():
-                    break
-                log2(INFO, "Wait for cache verification to finish")
-                if self._connection is None:
-                    # If the connection was closed while we were
-                    # waiting for it to become ready, start over.
-                    return self._wait()
-                else:
-                    self._connection.pending(30)
+            self._wait_sync()
+
+    def _wait_sync(self):
+        # If there is no mainloop running, this code needs
+        # to call poll() to cause asyncore to handle events.
+        while 1:
+            if self._ready.isSet():
+                break
+            log2(INFO, "Wait for cache verification to finish")
+            if self._connection is None:
+                # If the connection was closed while we were
+                # waiting for it to become ready, start over.
+                return self._wait()
+            else:
+                self._connection.pending(30)
 
     def close(self):
         """Storage API: finalize the storage, releasing external resources."""
@@ -414,6 +417,9 @@
         self._oids = []
         self._info.update(stub.get_info())
         self.verify_cache(stub)
+        if not conn.is_async():
+            log2(INFO, "Waiting for cache verification to finish")
+            self._wait_sync()
 
     def set_server_addr(self, addr):
         # Normalize server address and convert to string