Add call to wait_closed
method of asyncio.StreamWriter
This commit is contained in:
parent
d9883ee4f0
commit
5b32bfdd3f
|
@ -37,5 +37,6 @@ class RawConnection(IRawConnection):
|
||||||
"""
|
"""
|
||||||
return await self.reader.read(n)
|
return await self.reader.read(n)
|
||||||
|
|
||||||
def close(self) -> None:
|
async def close(self) -> None:
|
||||||
self.writer.close()
|
self.writer.close()
|
||||||
|
await self.writer.wait_closed()
|
||||||
|
|
|
@ -17,5 +17,5 @@ class IRawConnection(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def close(self) -> None:
|
async def close(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Swarm(INetwork):
|
||||||
)
|
)
|
||||||
except SecurityUpgradeFailure as error:
|
except SecurityUpgradeFailure as error:
|
||||||
# TODO: Add logging to indicate the failure
|
# TODO: Add logging to indicate the failure
|
||||||
raw_conn.close()
|
await raw_conn.close()
|
||||||
raise SwarmException(
|
raise SwarmException(
|
||||||
f"fail to upgrade the connection to a secured connection from {peer_id}"
|
f"fail to upgrade the connection to a secured connection from {peer_id}"
|
||||||
) from error
|
) from error
|
||||||
|
@ -128,7 +128,7 @@ class Swarm(INetwork):
|
||||||
)
|
)
|
||||||
except MuxerUpgradeFailure as error:
|
except MuxerUpgradeFailure as error:
|
||||||
# TODO: Add logging to indicate the failure
|
# TODO: Add logging to indicate the failure
|
||||||
secured_conn.close()
|
await secured_conn.close()
|
||||||
raise SwarmException(
|
raise SwarmException(
|
||||||
f"fail to upgrade the connection to a muxed connection from {peer_id}"
|
f"fail to upgrade the connection to a muxed connection from {peer_id}"
|
||||||
) from error
|
) from error
|
||||||
|
@ -215,7 +215,7 @@ class Swarm(INetwork):
|
||||||
)
|
)
|
||||||
except SecurityUpgradeFailure as error:
|
except SecurityUpgradeFailure as error:
|
||||||
# TODO: Add logging to indicate the failure
|
# TODO: Add logging to indicate the failure
|
||||||
raw_conn.close()
|
await raw_conn.close()
|
||||||
raise SwarmException(
|
raise SwarmException(
|
||||||
"fail to upgrade the connection to a secured connection"
|
"fail to upgrade the connection to a secured connection"
|
||||||
) from error
|
) from error
|
||||||
|
@ -226,7 +226,7 @@ class Swarm(INetwork):
|
||||||
)
|
)
|
||||||
except MuxerUpgradeFailure as error:
|
except MuxerUpgradeFailure as error:
|
||||||
# TODO: Add logging to indicate the failure
|
# TODO: Add logging to indicate the failure
|
||||||
secured_conn.close()
|
await secured_conn.close()
|
||||||
raise SwarmException(
|
raise SwarmException(
|
||||||
f"fail to upgrade the connection to a muxed connection from {peer_id}"
|
f"fail to upgrade the connection to a muxed connection from {peer_id}"
|
||||||
) from error
|
) from error
|
||||||
|
|
|
@ -36,8 +36,8 @@ class BaseSession(ISecureConn):
|
||||||
async def read(self, n: int = -1) -> bytes:
|
async def read(self, n: int = -1) -> bytes:
|
||||||
return await self.conn.read(n)
|
return await self.conn.read(n)
|
||||||
|
|
||||||
def close(self) -> None:
|
async def close(self) -> None:
|
||||||
self.conn.close()
|
await self.conn.close()
|
||||||
|
|
||||||
def get_local_peer(self) -> ID:
|
def get_local_peer(self) -> ID:
|
||||||
return self.local_peer
|
return self.local_peer
|
||||||
|
|
|
@ -40,7 +40,7 @@ class IMuxedConn(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def close(self) -> None:
|
async def close(self) -> None:
|
||||||
"""
|
"""
|
||||||
close connection
|
close connection
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -69,11 +69,11 @@ class Mplex(IMuxedConn):
|
||||||
def initiator(self) -> bool:
|
def initiator(self) -> bool:
|
||||||
return self.conn.initiator
|
return self.conn.initiator
|
||||||
|
|
||||||
def close(self) -> None:
|
async def close(self) -> None:
|
||||||
"""
|
"""
|
||||||
close the stream muxer and underlying raw connection
|
close the stream muxer and underlying raw connection
|
||||||
"""
|
"""
|
||||||
self.conn.close()
|
await self.conn.close()
|
||||||
|
|
||||||
def is_closed(self) -> bool:
|
def is_closed(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user