From 1c98e510f521fbf85936286e0554a4e404e75eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Tue, 8 Dec 2020 21:56:35 +0100 Subject: [PATCH] handle ENOMEM during mremap() --- README.md | 1 + setup.py | 2 +- tempsdb/chunks.pyx | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 48789b7..01825e0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ You will need to have both snakehouse and satella installed. ## v0.4.4 * more error conditions during mmap will be supported as well +* ENOMEM will be correctly handled during resize operation ## v0.4.3 diff --git a/setup.py b/setup.py index 848e2c2..679b03f 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ if 'CI' in os.environ: setup(name='tempsdb', - version='0.4.4a2', + version='0.4.4a3', 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 f3e7db6..d03d898 100644 --- a/tempsdb/chunks.pyx +++ b/tempsdb/chunks.pyx @@ -217,7 +217,13 @@ cdef class Chunk: ba = bytearray(self.page_size) ba[self.page_size-FOOTER_SIZE:self.page_size] = STRUCT_L.pack(self.entries) self.file.write(ba) - self.mmap.resize(self.file_size) + try: + self.mmap.resize(self.file_size) + except OSError as e: + if e.errno == 12: # ENOMEM + self.switch_to_descriptor_based_access() + else: + raise finally: if self.file_lock_object: self.file_lock_object.release() -- GitLab