Commit 6efddbf0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e563a4e3
...@@ -34,12 +34,13 @@ from cpython.pystate cimport PyGILState_Ensure, PyGILState_Release, PyGILState_S ...@@ -34,12 +34,13 @@ from cpython.pystate cimport PyGILState_Ensure, PyGILState_Release, PyGILState_S
cdef extern from "Python.h": cdef extern from "Python.h":
int PyRun_SimpleString(const char *) int PyRun_SimpleString(const char *)
# read0_nogil accesses mem[0] with GIL released and returns first byte read from there. # read_nogil reads mem with GIL released and returns its content.
def read0_nogil(const unsigned char[::1] mem not None) -> int: 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 cdef unsigned char b
with nogil: with nogil:
b = mem[0] b = mem[0]
return b return bytes(bytearray([b]))
# ---- signal handling ---- # ---- signal handling ----
......
...@@ -42,7 +42,7 @@ from zodbtools.util import ashex as h, fromhex ...@@ -42,7 +42,7 @@ from zodbtools.util import ashex as h, fromhex
from pytest import raises from pytest import raises
from six import reraise from six import reraise
from .internal import mm 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: # setup:
# - create test database, compute zurl and mountpoint for wcfs # - create test database, compute zurl and mountpoint for wcfs
...@@ -579,11 +579,11 @@ class tFile: ...@@ -579,11 +579,11 @@ class tFile:
# access data with released GIL so that the thread that reads data from # access data with released GIL so that the thread that reads data from
# head/watch can receive pin message. Be careful to handle cancelation, # 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 # so that on error in another worker we don't get stuck and the
# be propagated to wait and reported. # error can be propagated to wait and reported.
have_read = chan(1) have_read = chan(1)
def _(): def _():
b = read0_nogil(blkview) b = read_nogil(blkview[0:1])
have_read.send(b) have_read.send(b)
t.tdb._blkaccess(t.zf, blk) t.tdb._blkaccess(t.zf, blk)
go(_) go(_)
...@@ -595,7 +595,7 @@ class tFile: ...@@ -595,7 +595,7 @@ class tFile:
raise ctx.err() raise ctx.err()
b = _rx b = _rx
ev.append('read ' + chr(b)) ev.append('read ' + b)
ev = doCheckingPin(_, pinokByWLink) ev = doCheckingPin(_, pinokByWLink)
# XXX hack - wlinks are notified and emit events simultaneously - we # XXX hack - wlinks are notified and emit events simultaneously - we
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment