Skip to content

Commit d4fb405

Browse files
authored
If only reading the mmap file, open in read-only mode.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
1 parent 18017c6 commit d4fb405

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prometheus_client/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class _MmapedDict(object):
505505
Not thread safe.
506506
"""
507507
def __init__(self, filename, read_mode=False):
508-
self._f = open(filename, 'a+b')
508+
self._f = open(filename, 'rb' if read_mode else 'a+b')
509509
if os.fstat(self._f.fileno()).st_size == 0:
510510
self._f.truncate(_INITIAL_MMAP_SIZE)
511511
self._capacity = os.fstat(self._f.fileno()).st_size

0 commit comments

Comments
 (0)