diff --git a/wcfs/internal/wcfs_test.pyx b/wcfs/internal/wcfs_test.pyx index 1981f27d7f765961f835cae19581d0b29666874e..7465d7a55672695fc40a73c7110c4c15fcd0eb13 100644 --- a/wcfs/internal/wcfs_test.pyx +++ b/wcfs/internal/wcfs_test.pyx @@ -34,12 +34,13 @@ from cpython.pystate cimport PyGILState_Ensure, PyGILState_Release, PyGILState_S cdef extern from "Python.h": int PyRun_SimpleString(const char *) -# read0_nogil accesses mem[0] with GIL released and returns first byte read from there. -def read0_nogil(const unsigned char[::1] mem not None) -> int: +# read_nogil reads mem with GIL released and returns its content. +def read_nogil(const unsigned char[::1] mem not None) -> bytes: + assert len(mem) == 1, "read_nogil: only [1] mem is supported for now" cdef unsigned char b with nogil: b = mem[0] - return b + return bytes(bytearray([b])) # ---- signal handling ---- diff --git a/wcfs/wcfs_test.py b/wcfs/wcfs_test.py index 74133777ec82cac833383e4bff83fc52b66416cc..d278c5aa3f0bde650dbc190de58052e03c739b65 100644 --- a/wcfs/wcfs_test.py +++ b/wcfs/wcfs_test.py @@ -42,7 +42,7 @@ from zodbtools.util import ashex as h, fromhex from pytest import raises from six import reraise from .internal import mm -from .internal.wcfs_test import read0_nogil, install_sigbus_trap +from .internal.wcfs_test import read_nogil, install_sigbus_trap # setup: # - create test database, compute zurl and mountpoint for wcfs @@ -579,11 +579,11 @@ class tFile: # access data with released GIL so that the thread that reads data from # head/watch can receive pin message. Be careful to handle cancelation, - # so that on error in another worker we don't stuck and the error can - # be propagated to wait and reported. + # so that on error in another worker we don't get stuck and the + # error can be propagated to wait and reported. have_read = chan(1) def _(): - b = read0_nogil(blkview) + b = read_nogil(blkview[0:1]) have_read.send(b) t.tdb._blkaccess(t.zf, blk) go(_) @@ -595,7 +595,7 @@ class tFile: raise ctx.err() b = _rx - ev.append('read ' + chr(b)) + ev.append('read ' + b) ev = doCheckingPin(_, pinokByWLink) # XXX hack - wlinks are notified and emit events simultaneously - we