Introduces IO abstractions apart from asyncio or those attached to IRawConnection

Also adds `msgio` utilities to mirror the Go implementation
This commit is contained in:
Alex Stokes
2019-09-03 21:42:45 -07:00
parent cd3e093001
commit 8e8318aa5c
7 changed files with 154 additions and 32 deletions

View File

@ -20,11 +20,12 @@ class InMemoryConnection(IRawConnection):
self.closed = False
async def write(self, data: bytes) -> None:
async def write(self, data: bytes) -> int:
if self.closed:
raise Exception("InMemoryConnection is closed for writing")
await self.send_queue.put(data)
return len(data)
async def read(self, n: int = -1) -> bytes:
"""