diff --git a/src/ZEO/ClientStorage.py b/src/ZEO/ClientStorage.py index 0e3aac28f..c929c5f3a 100644 --- a/src/ZEO/ClientStorage.py +++ b/src/ZEO/ClientStorage.py @@ -784,8 +784,7 @@ def tpc_end(self, txn): self._commit_lock.release() def lastTransaction(self): - with self._lock: - return self._cache.getLastTid() + return self._cache.getLastTid() def tpc_abort(self, txn, timeout=None): """Storage API: abort a transaction. diff --git a/src/ZEO/asyncio/client.py b/src/ZEO/asyncio/client.py index 5078e3c92..d84eee790 100644 --- a/src/ZEO/asyncio/client.py +++ b/src/ZEO/asyncio/client.py @@ -624,21 +624,6 @@ def call_threadsafe(self, future, method, args): # Special methods because they update the cache. - def load_threadsafe(self, future, oid): - data = self.cache.load(oid) - if data is not None: - future.set_result(data) - elif self.ready: - @self.protocol.promise('loadEx', oid) - def load(data): - future.set_result(data) - data, tid = data - self.cache.store(oid, tid, None, data) - - load.catch(future.set_exception) - else: - self._when_ready(self.load_threadsafe, future, oid) - def load_before_threadsafe(self, future, oid, tid): data = self.cache.loadBefore(oid, tid) if data is not None: @@ -690,8 +675,8 @@ def invalidateTransaction(self, tid, oids): if self.ready: for oid in oids: self.cache.invalidate(oid, tid) - self.cache.setLastTid(tid) self.client.invalidateTransaction(tid, oids) + self.cache.setLastTid(tid) def serialnos(self, serials): # Before delegating, check for errors (likely ConflictErrors) @@ -769,9 +754,6 @@ def async(self, method, *args): def async_iter(self, it): return self.__call(self.client.call_async_iter_threadsafe, it) - def load(self, oid): - return self.__call(self.client.load_threadsafe, oid) - def load_before(self, oid, tid): return self.__call(self.client.load_before_threadsafe, oid, tid) diff --git a/src/ZEO/asyncio/tests.py b/src/ZEO/asyncio/tests.py index a30e4170f..09a93781b 100644 --- a/src/ZEO/asyncio/tests.py +++ b/src/ZEO/asyncio/tests.py @@ -15,6 +15,7 @@ from .testing import Loop from .client import ClientRunner, Fallback from ..Exceptions import ClientDisconnected +from ..ClientStorage import m64 class AsyncTests(setupstack.TestCase, ClientRunner): @@ -143,17 +144,17 @@ def testBasics(self): self.assertEqual(parse(transport.pop()), (0, True, 'bar', (3, 4))) # Loading objects gets special handling to leverage the cache. - loaded = self.load(b'1'*8) + loaded = self.load_before(b'1'*8, m64) # The data wasn't in the cache, so we make a server call: self.assertEqual(parse(transport.pop()), - (5, False, 'loadEx', (b'1'*8,))) - respond(5, (b'data', b'a'*8)) - self.assertEqual(loaded.result(), (b'data', b'a'*8)) + (5, False, 'loadBefore', (b'1'*8, m64))) + respond(5, (b'data', b'a'*8, None)) + self.assertEqual(loaded.result(), (b'data', b'a'*8, None)) # If we make another request, it will be satisfied from the cache: - loaded = self.load(b'1'*8) - self.assertEqual(loaded.result(), (b'data', b'a'*8)) + loaded = self.load_before(b'1'*8, m64) + self.assertEqual(loaded.result(), (b'data', b'a'*8, None)) self.assertFalse(transport.data) # Let's send an invalidation: @@ -162,11 +163,11 @@ def testBasics(self): wrapper.invalidateTransaction.reset_mock() # Now, if we try to load current again, we'll make a server request. - loaded = self.load(b'1'*8) + loaded = self.load_before(b'1'*8, m64) self.assertEqual(parse(transport.pop()), - (6, False, 'loadEx', (b'1'*8,))) - respond(6, (b'data2', b'b'*8)) - self.assertEqual(loaded.result(), (b'data2', b'b'*8)) + (6, False, 'loadBefore', (b'1'*8, m64))) + respond(6, (b'data2', b'b'*8, None)) + self.assertEqual(loaded.result(), (b'data2', b'b'*8, None)) # Loading non-current data may also be satisfied from cache loaded = self.load_before(b'1'*8, b'b'*8) @@ -212,11 +213,11 @@ def finished_cb(tid): # If the protocol is disconnected, it will reconnect and will # resolve outstanding requests with exceptions: - loaded = self.load(b'1'*8) + loaded = self.load_before(b'1'*8, m64) f1 = self.call('foo', 1, 2) self.assertFalse(loaded.done() or f1.done()) self.assertEqual(parse(transport.pop()), - [(9, False, 'loadEx', (b'1'*8,)), + [(9, False, 'loadBefore', (b'1'*8, m64)), (10, False, 'foo', (1, 2))], ) exc = TypeError(43) diff --git a/src/ZEO/tests/testZEO.py b/src/ZEO/tests/testZEO.py index b5325cd88..10f647cfd 100644 --- a/src/ZEO/tests/testZEO.py +++ b/src/ZEO/tests/testZEO.py @@ -920,12 +920,12 @@ def tpc_finish_error(): >>> addr, admin = start_server() - >>> db = ZEO.DB(addr) + >>> client = ZEO.client(addr) + >>> db = ZODB.DB(client) >>> conn = db.open() >>> conn.root.x = 1 >>> t = conn.transaction_manager.get() - >>> client = conn._storage - >>> client.tpc_begin(t) + >>> conn._storage.tpc_begin(t) >>> conn.commit(t) >>> _ = client.tpc_vote(t)