From 96659e2c28f52e42d93a5edd164390cf7b61dcd0 Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Tue, 2 Aug 2016 10:12:58 -0400 Subject: [PATCH] use ZODB.utils.maxtid rather than z64 --- src/ZEO/ClientStorage.py | 5 +---- src/ZEO/asyncio/tests.py | 35 +++++++++++++++++++---------------- src/ZEO/tests/testZEO.py | 6 +++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/ZEO/ClientStorage.py b/src/ZEO/ClientStorage.py index a3fcc9ea4..ef3c91fcc 100644 --- a/src/ZEO/ClientStorage.py +++ b/src/ZEO/ClientStorage.py @@ -51,9 +51,6 @@ logger = logging.getLogger(__name__) -# max signed 64-bit value ~ infinity :) Signed cuz LBTree and TimeStamp -m64 = b'\x7f\xff\xff\xff\xff\xff\xff\xff' - def tid2time(tid): return str(TimeStamp(tid)) @@ -498,7 +495,7 @@ def loadSerial(self, oid, serial): return self._call('loadSerial', oid, serial) def load(self, oid, version=''): - result = self.loadBefore(oid, m64) + result = self.loadBefore(oid, utils.maxtid) if result is None: raise POSException.POSKeyError(oid) return result[:2] diff --git a/src/ZEO/asyncio/tests.py b/src/ZEO/asyncio/tests.py index c18150e69..d0a37a77d 100644 --- a/src/ZEO/asyncio/tests.py +++ b/src/ZEO/asyncio/tests.py @@ -9,6 +9,7 @@ from concurrent.futures import Future import mock from ZODB.POSException import ReadOnlyError +from ZODB.utils import maxtid import collections import logging @@ -16,7 +17,6 @@ import unittest from ..Exceptions import ClientDisconnected, ProtocolError -from ..ClientStorage import m64 from .testing import Loop from .client import ClientRunner, Fallback @@ -192,17 +192,18 @@ def testClientBasics(self): self.assertEqual(self.pop(), (0, True, 'bar', (3, 4))) # Loading objects gets special handling to leverage the cache. - loaded = self.load_before(b'1'*8, m64) + loaded = self.load_before(b'1'*8, maxtid) # The data wasn't in the cache, so we made a server call: - self.assertEqual(self.pop(), - ((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64))) + self.assertEqual( + self.pop(), + ((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid))) # Note load_before uses the oid as the message id. - self.respond((b'1'*8, m64), (b'data', b'a'*8, None)) + self.respond((b'1'*8, maxtid), (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_before(b'1'*8, m64) + loaded = self.load_before(b'1'*8, maxtid) self.assertEqual(loaded.result(), (b'data', b'a'*8, None)) self.assertFalse(transport.data) @@ -210,15 +211,16 @@ def testClientBasics(self): self.send('invalidateTransaction', b'b'*8, [b'1'*8]) # Now, if we try to load current again, we'll make a server request. - loaded = self.load_before(b'1'*8, m64) + loaded = self.load_before(b'1'*8, maxtid) # Note that if we make another request for the same object, # the requests will be collapsed: - loaded2 = self.load_before(b'1'*8, m64) + loaded2 = self.load_before(b'1'*8, maxtid) - self.assertEqual(self.pop(), - ((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64))) - self.respond((b'1'*8, m64), (b'data2', b'b'*8, None)) + self.assertEqual( + self.pop(), + ((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid))) + self.respond((b'1'*8, maxtid), (b'data2', b'b'*8, None)) self.assertEqual(loaded.result(), (b'data2', b'b'*8, None)) self.assertEqual(loaded2.result(), (b'data2', b'b'*8, None)) @@ -267,13 +269,14 @@ def finished_cb(tid): # If the protocol is disconnected, it will reconnect and will # resolve outstanding requests with exceptions: - loaded = self.load_before(b'1'*8, m64) + loaded = self.load_before(b'1'*8, maxtid) f1 = self.call('foo', 1, 2) self.assertFalse(loaded.done() or f1.done()) - self.assertEqual(self.pop(), - [((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64)), - (6, False, 'foo', (1, 2))], - ) + self.assertEqual( + self.pop(), + [((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid)), + (6, False, 'foo', (1, 2))], + ) exc = TypeError(43) self.assertFalse(wrapper.notify_disconnected.called) diff --git a/src/ZEO/tests/testZEO.py b/src/ZEO/tests/testZEO.py index 3e3ef3755..1783fcfa5 100644 --- a/src/ZEO/tests/testZEO.py +++ b/src/ZEO/tests/testZEO.py @@ -16,7 +16,7 @@ import multiprocessing import re -from ZEO.ClientStorage import ClientStorage, m64 +from ZEO.ClientStorage import ClientStorage from ZEO.tests import forker, Cache, CommitLockTests, ThreadTests from ZEO.tests import IterationTests from ZEO._compat import PY3 @@ -26,7 +26,7 @@ MTStorage, ReadOnlyStorage, IteratorStorage, RecoveryStorage from ZODB.tests.MinPO import MinPO from ZODB.tests.StorageTestBase import zodb_unpickle -from ZODB.utils import p64, u64, z64 +from ZODB.utils import maxtid, p64, u64, z64 from zope.testing import renormalizing import doctest @@ -1401,7 +1401,7 @@ def gracefully_handle_abort_while_storing_many_blobs(): get processed. Before we fixed this by making tpc_finish a synchronous call to the server. we'd get some sort of error here. - >>> _ = client._call('loadBefore', b'\0'*8, m64) + >>> _ = client._call('loadBefore', b'\0'*8, maxtid) >>> c.close()