Skip to content

Commit

Permalink
Fix destructor for delayed mmap dataset case (#6703)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikołaj Błaż <[email protected]>
Co-authored-by: Eric Harper <[email protected]>
  • Loading branch information
mikolajblaz and ericharper committed Jun 21, 2023
1 parent 24837af commit 328bbbb
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ def _do_init(self, path, skip_warmup=True, delay_data_mmap=False):
self._create_data_mmap(skip_warmup)
else:
logging.info(" skip creating data numpy buffer of mmap...")
self._bin_buffer_mmap = None
self._bin_buffer = None

def _create_data_mmap(self, skip_warmup):
if not skip_warmup:
Expand All @@ -524,7 +526,8 @@ def _create_data_mmap(self, skip_warmup):
self._bin_buffer = memoryview(self._bin_buffer_mmap)

def __del__(self):
self._bin_buffer_mmap._mmap.close()
if self._bin_buffer_mmap is not None:
self._bin_buffer_mmap._mmap.close()
del self._bin_buffer_mmap
del self._index

Expand Down

0 comments on commit 328bbbb

Please sign in to comment.