Immutable writing now knows when it's finished.

This commit is contained in:
Itamar Turner-Trauring 2022-01-17 14:06:21 -05:00
parent 4ea6bf2381
commit 25e2100219
2 changed files with 4 additions and 7 deletions

View File

@ -403,12 +403,10 @@ class BucketWriter(object):
self.ss.count("write")
# Return whether the whole thing has been written. See
# https://github.com/mlenzen/collections-extended/issues/169 for why
# https://github.com/mlenzen/collections-extended/issues/169 and
# https://github.com/mlenzen/collections-extended/issues/172 for why
# it's done this way.
print([tuple(mr) for mr in self._already_written.ranges()])
return [tuple(mr) for mr in self._already_written.ranges()] == [
(0, self._max_size, True)
]
return sum([mr.stop - mr.start for mr in self._already_written.ranges()]) == self._max_size
def close(self):
precondition(not self.closed)

View File

@ -279,10 +279,9 @@ class Bucket(unittest.TestCase):
The ``BucketWriter.write()`` return true if and only if the maximum
size has been reached via potentially overlapping writes.
"""
length = 100
incoming, final = self.make_workdir("overlapping_writes_{}".format(uuid4()))
bw = BucketWriter(
self, incoming, final, length, self.make_lease(), Clock()
self, incoming, final, 100, self.make_lease(), Clock()
)
local_written = [0] * 100
for offset in offsets: