mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-04-02 20:11:28 +00:00
Use RawConnection.read
Instead of accessing its reader and writer directly. TODO: considering add `ReaderWriterCloser` interface and let connection and stream inherit from it.
This commit is contained in:
@ -39,9 +39,12 @@ class RawConnection(IRawConnection):
|
||||
async with self._drain_lock:
|
||||
await self.writer.drain()
|
||||
|
||||
async def read(self) -> bytes:
|
||||
line = await self.reader.readline()
|
||||
return line.rstrip(b"\n")
|
||||
async def read(self, n: int = -1) -> bytes:
|
||||
"""
|
||||
Read up to ``n`` bytes from the underlying stream.
|
||||
This call is delegated directly to the underlying ``self.reader``.
|
||||
"""
|
||||
return await self.reader.read(n)
|
||||
|
||||
def close(self) -> None:
|
||||
self.writer.close()
|
||||
|
||||
Reference in New Issue
Block a user