fix: linting error related to read

This commit is contained in:
Jinesh Jain
2025-07-08 19:11:56 +05:30
parent 8fb664bfdf
commit e65e38a3f1

View File

@ -140,6 +140,7 @@ class MplexStream(IMuxedStream):
:return: bytes actually read
"""
await self.rw_lock.acquire_read()
payload: bytes = b""
try:
if n is not None and n < 0:
raise ValueError(
@ -180,12 +181,12 @@ class MplexStream(IMuxedStream):
"This should never happen."
) from error
self._buf.extend(self._read_return_when_blocked())
payload = self._buf[:n]
self._buf = self._buf[len(payload) :]
return bytes(payload)
chunk = self._buf[:n]
self._buf = self._buf[len(chunk) :]
payload = bytes(chunk)
finally:
await self.rw_lock.release_read()
return b""
return payload
async def write(self, data: bytes) -> None:
"""