Temporarily enforce requirement that allocated size matches actual size of an immutable.

This commit is contained in:
Itamar Turner-Trauring 2022-08-16 13:11:06 -04:00
parent 7dd346a32d
commit 2e5662aa91

View File

@ -419,14 +419,19 @@ class BucketWriter(object):
self._already_written.set(True, offset, end)
self.ss.add_latency("write", self._clock.seconds() - start)
self.ss.count("write")
return self._is_finished()
# Return whether the whole thing has been written. See
# https://github.com/mlenzen/collections-extended/issues/169 and
# https://github.com/mlenzen/collections-extended/issues/172 for why
# it's done this way.
def _is_finished(self):
"""
Return whether the whole thing has been written.
"""
return sum([mr.stop - mr.start for mr in self._already_written.ranges()]) == self._max_size
def close(self):
# TODO this can't actually be enabled, because it's not backwards
# compatible. But it's useful for testing, so leaving it on until the
# branch is ready for merge.
assert self._is_finished()
precondition(not self.closed)
self._timeout.cancel()
start = self._clock.seconds()