Commit b9c4b220 authored by Jeremy Hylton's avatar Jeremy Hylton

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.
parent 3d6968aa
......@@ -293,18 +293,21 @@ class ClientStorage:
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 @@ class ClientStorage:
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
......
......@@ -205,7 +205,6 @@ class ConnectionTests(CommonSetupTearDown):
self._dostore()
break
except ClientDisconnected:
self._storage.sync()
time.sleep(0.5)
def checkReadOnlyClient(self):
......@@ -392,7 +391,6 @@ class ConnectionTests(CommonSetupTearDown):
"Error after server restart; retrying.",
error=sys.exc_info())
get_transaction().abort()
self._storage.sync()
# XXX This is a bloody pain. We're placing a heavy burden
# on users to catch a plethora of exceptions in order to
# write robust code. Need to think about implementing
......@@ -645,7 +643,6 @@ class ReconnectionTests(CommonSetupTearDown):
# quickly and the test fails because it doesn't wait
# long enough for the client.
time.sleep(0.1)
self._storage.sync()
else:
self.fail("Couldn't store after starting a read-write server")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment