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,6 +293,9 @@ class ClientStorage: ...@@ -293,6 +293,9 @@ class ClientStorage:
break break
log2(INFO, "Wait for cache verification to finish") log2(INFO, "Wait for cache verification to finish")
else: else:
self._wait_sync()
def _wait_sync(self):
# If there is no mainloop running, this code needs # If there is no mainloop running, this code needs
# to call poll() to cause asyncore to handle events. # to call poll() to cause asyncore to handle events.
while 1: while 1:
...@@ -414,6 +417,9 @@ class ClientStorage: ...@@ -414,6 +417,9 @@ class ClientStorage:
self._oids = [] self._oids = []
self._info.update(stub.get_info()) self._info.update(stub.get_info())
self.verify_cache(stub) 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): def set_server_addr(self, addr):
# Normalize server address and convert to string # Normalize server address and convert to string
......
...@@ -205,7 +205,6 @@ class ConnectionTests(CommonSetupTearDown): ...@@ -205,7 +205,6 @@ class ConnectionTests(CommonSetupTearDown):
self._dostore() self._dostore()
break break
except ClientDisconnected: except ClientDisconnected:
self._storage.sync()
time.sleep(0.5) time.sleep(0.5)
def checkReadOnlyClient(self): def checkReadOnlyClient(self):
...@@ -392,7 +391,6 @@ class ConnectionTests(CommonSetupTearDown): ...@@ -392,7 +391,6 @@ class ConnectionTests(CommonSetupTearDown):
"Error after server restart; retrying.", "Error after server restart; retrying.",
error=sys.exc_info()) error=sys.exc_info())
get_transaction().abort() get_transaction().abort()
self._storage.sync()
# XXX This is a bloody pain. We're placing a heavy burden # XXX This is a bloody pain. We're placing a heavy burden
# on users to catch a plethora of exceptions in order to # on users to catch a plethora of exceptions in order to
# write robust code. Need to think about implementing # write robust code. Need to think about implementing
...@@ -645,7 +643,6 @@ class ReconnectionTests(CommonSetupTearDown): ...@@ -645,7 +643,6 @@ class ReconnectionTests(CommonSetupTearDown):
# quickly and the test fails because it doesn't wait # quickly and the test fails because it doesn't wait
# long enough for the client. # long enough for the client.
time.sleep(0.1) time.sleep(0.1)
self._storage.sync()
else: else:
self.fail("Couldn't store after starting a read-write server") 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