Skip to content

Commit

Permalink
use ZODB.utils.maxtid rather than z64
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Aug 2, 2016
1 parent 64635dd commit 96659e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/ZEO/ClientStorage.py
Expand Up @@ -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))

Expand Down Expand Up @@ -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]
Expand Down
35 changes: 19 additions & 16 deletions src/ZEO/asyncio/tests.py
Expand Up @@ -9,14 +9,14 @@
from concurrent.futures import Future
import mock
from ZODB.POSException import ReadOnlyError
from ZODB.utils import maxtid

import collections
import logging
import struct
import unittest

from ..Exceptions import ClientDisconnected, ProtocolError
from ..ClientStorage import m64

from .testing import Loop
from .client import ClientRunner, Fallback
Expand Down Expand Up @@ -192,33 +192,35 @@ 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)

# Let's send an invalidation:
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))

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

0 comments on commit 96659e2

Please sign in to comment.