Skip to content

Commit

Permalink
Oh git -- rest of last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Jun 17, 2016
1 parent dcbeab4 commit 8c3b6ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 36 deletions.
3 changes: 1 addition & 2 deletions src/ZEO/ClientStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 1 addition & 19 deletions src/ZEO/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
25 changes: 13 additions & 12 deletions src/ZEO/asyncio/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/ZEO/tests/testZEO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8c3b6ee

Please sign in to comment.