feat: improve performance of reading from the socket during unmarshall (#200)
This commit is contained in:
parent
a17d6d0fd0
commit
e5d355ff40
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -65,7 +65,7 @@ jobs:
|
||||
if [ "${{ matrix.extension }}" = "skip_cython" ]; then
|
||||
SKIP_CYTHON=1 poetry install --only=main,dev
|
||||
else
|
||||
poetry install --only=main,dev
|
||||
REQUIRE_CYTHON=1 poetry install --only=main,dev
|
||||
fi
|
||||
- name: Test with Pytest
|
||||
run: export $(dbus-launch); poetry run pytest --cov-report=xml --timeout=5
|
||||
|
||||
@ -123,6 +123,7 @@ cdef class Unmarshaller:
|
||||
|
||||
@cython.locals(
|
||||
msg=cython.bytes,
|
||||
recv=cython.tuple
|
||||
)
|
||||
cdef bytes _read_sock(self, object length)
|
||||
|
||||
|
||||
@ -250,13 +250,16 @@ class Unmarshaller:
|
||||
from the read itself"""
|
||||
# This will raise BlockingIOError if there is no data to read
|
||||
# which we store in the MARSHALL_STREAM_END_ERROR object
|
||||
msg, ancdata, _flags, _addr = self._sock.recvmsg(length, UNIX_FDS_CMSG_LENGTH) # type: ignore[union-attr]
|
||||
for level, type_, data in ancdata:
|
||||
if not (level == SOL_SOCKET and type_ == SCM_RIGHTS):
|
||||
continue
|
||||
self._unix_fds.extend(
|
||||
ARRAY("i", data[: len(data) - (len(data) % MAX_UNIX_FDS_SIZE)])
|
||||
)
|
||||
recv = self._sock.recvmsg(length, UNIX_FDS_CMSG_LENGTH) # type: ignore[union-attr]
|
||||
msg = recv[0]
|
||||
ancdata = recv[1]
|
||||
if ancdata:
|
||||
for level, type_, data in ancdata:
|
||||
if not (level == SOL_SOCKET and type_ == SCM_RIGHTS):
|
||||
continue
|
||||
self._unix_fds.extend(
|
||||
ARRAY("i", data[: len(data) - (len(data) % MAX_UNIX_FDS_SIZE)])
|
||||
)
|
||||
|
||||
return msg
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user