Fix Mplex and Swarm

This commit is contained in:
mhchia
2019-11-29 19:09:56 +08:00
parent ec43c25b45
commit 1e600ea7e0
13 changed files with 232 additions and 122 deletions

View File

@ -23,6 +23,10 @@ class TrioReadWriteCloser(ReadWriteCloser):
raise IOException(error)
async def read(self, n: int = -1) -> bytes:
if n == 0:
# Check point
await trio.sleep(0)
return b""
max_bytes = n if n != -1 else None
try:
return await self.stream.receive_some(max_bytes)