Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/blosc2/blosc2_ext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4184,16 +4184,17 @@ cdef class SChunk:
len_data = buf.len
nchunks = (len_data + chunksize - 1) // chunksize if len_data > 0 else 0
len_chunk = chunksize
for i in range(nchunks):
if i == (nchunks - 1):
len_chunk = len_data - i * chunksize
index = i * chunksize
rc = _store_buffer(self.schunk, _WRITE_APPEND, i, buf_ptr + index, len_chunk)
if rc < 0:
PyBuffer_Release(&buf)
_raise_callback_error()
raise RuntimeError("Could not compress and append the chunk")
PyBuffer_Release(&buf)
try:
for i in range(nchunks):
if i == (nchunks - 1):
len_chunk = len_data - i * chunksize
index = i * chunksize
rc = _store_buffer(self.schunk, _WRITE_APPEND, i, buf_ptr + index, len_chunk)
if rc < 0:
_raise_callback_error()
raise RuntimeError("Could not compress and append the chunk")
finally:
PyBuffer_Release(&buf)

@property
def c_schunk(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_schunk_data_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def test_data_writes(storage, releasegil):
np.testing.assert_array_equal(got, exp)


def test_data_writes_reach_prefilter(storage):
def test_data_writes_reach_prefilter(storage, releasegil):
# The prefilter computes each item from its position, so it must see the right chunk number.
# With the GIL held only: Python prefilters crash with set_releasegil(True).
# It runs Python, so the writes keep the GIL even with set_releasegil(True).
schunk = new_schunk(storage, nthreads=1)

@schunk.prefilter(np.int32, np.int32)
Expand Down
Loading