Mplex: catch RawConnError when writing

Also, do nothing in `MplexStream.reset` if `MuxedConnUnavailable` is
raised when sending the message.
This commit is contained in:
mhchia
2020-02-04 21:57:59 +08:00
parent f884bfa39e
commit c0ab609559
2 changed files with 13 additions and 2 deletions

View File

@ -166,7 +166,13 @@ class Mplex(IMuxedConn):
:param _bytes: byte array to write
:return: length written
"""
await self.secured_conn.write(_bytes)
try:
await self.secured_conn.write(_bytes)
except RawConnError as e:
raise MplexUnavailable(
"failed to write message to the underlying connection"
) from e
return len(_bytes)
async def handle_incoming(self) -> None: