diff --git a/README.md b/README.md index 58d7212a19cc2a3bd3e5579d101e3f6aa667e7b8..48789b76b7069fd008cca54857762d74327212e5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ You will need to have both snakehouse and satella installed. ## v0.4.4 -* _TBA_ +* more error conditions during mmap will be supported as well ## v0.4.3 diff --git a/setup.py b/setup.py index 597764bd0a6bf1c4dd27a5601471a83a920f472e..848e2c20cf9b111bd1b0db2ba73a349eaf4d190d 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ if 'CI' in os.environ: setup(name='tempsdb', - version='0.4.4a1', + version='0.4.4a2', packages=['tempsdb'], install_requires=['satella>=2.14.21', 'ujson'], ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb')), ], diff --git a/tempsdb/chunks.pyx b/tempsdb/chunks.pyx index 417c75637917f819c92d5ca8f650bc340117c6e1..f3e7db68dc8fac79a7b13511b4a9484b100ce4da 100644 --- a/tempsdb/chunks.pyx +++ b/tempsdb/chunks.pyx @@ -30,7 +30,7 @@ cdef class AlternativeMMap: def __init__(self, io_file: io.BinaryIO, file_lock_object): self.io = io_file - self.io.seek(0, 2) + self.io.seek(0, io.SEEK_END) self.size = self.io.tell() self.file_lock_object = file_lock_object @@ -117,7 +117,10 @@ cdef class Chunk: try: self.mmap = mmap.mmap(self.file.fileno(), 0) except OSError as e: - if e.errno == 12: # Cannot allocate memory + if e.errno in (11, # EAGAIN - memory is too low + 12, # ENOMEM - no memory space available + 19, # ENODEV - fs does not support mmapping + 75): # EOVERFLOW - too many pages would have been used self.file_lock_object = threading.Lock() self.mmap = AlternativeMMap(self.file, self.file_lock_object) else: @@ -210,7 +213,7 @@ cdef class Chunk: self.file_lock_object.acquire() try: self.file_size += self.page_size - self.file.seek(0, 2) + self.file.seek(0, io.SEEK_END) ba = bytearray(self.page_size) ba[self.page_size-FOOTER_SIZE:self.page_size] = STRUCT_L.pack(self.entries) self.file.write(ba)