Commit 8c3b6ee0 authored by Jim Fulton's avatar Jim Fulton

Oh git -- rest of last commit

parent dcbeab41
......@@ -784,8 +784,7 @@ class ClientStorage(object):
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.
......
......@@ -624,21 +624,6 @@ class Client:
# 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 @@ class Client:
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 @@ class ClientRunner:
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)
......
......@@ -15,6 +15,7 @@ import ZEO.Exceptions
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 @@ class AsyncTests(setupstack.TestCase, ClientRunner):
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 @@ class AsyncTests(setupstack.TestCase, ClientRunner):
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 @@ class AsyncTests(setupstack.TestCase, ClientRunner):
# 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)
......
......@@ -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)
......
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