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
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 ----
......
......@@ -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
......
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