8000 Fix double doubling of mmap file capacity (#138) · pythonAI/client_python@6a8d85e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a8d85e

Browse files
juliusvbrian-brazil
authored andcommitted
Fix double doubling of mmap file capacity (prometheus#138)
1 parent 60e9e4c commit 6a8d85e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

prometheus_client/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class _MmapedDict(object):
315315
The file starts with a 4 byte int, indicating how much of it is used.
316316
Then 4 bytes of padding.
317317
There's then a number of entries, consisting of a 4 byte int which is the
318-
side of the next field, a utf-8 encoded string key, padding to a 8 byte
318+
size of the next field, a utf-8 encoded string key, padding to a 8 byte
319319
alignment, and then a 8 byte float which is the value.
320320
"""
321321
def __init__(self, filename):
@@ -343,7 +343,7 @@ def _init_value(self, key):
343343
value = struct.pack('i{0}sd'.format(len(padded)).encode(), len(encoded), padded, 0.0)
344344
while self._used + len(value) > self._capacity:
345345
self._capacity *= 2
346-
self._f.truncate(self._capacity * 2)
346+
self._f.truncate(self._capacity)
347347
self._m = mmap.mmap(self._f.fileno(), self._capacity)
348348
self._m[self._used:self._used + len(value)] = value
349349

0 commit comments

Comments
 (0)
0