mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Adds exception handling in TCPListener.listen()
This commit is contained in:
committed by
Paul Robinson
parent
e076a038bc
commit
bb21af7694
@ -63,8 +63,14 @@ class TCPListener(IListener):
|
||||
await trio.serve_tcp(handler, port, host=host, task_status=task_status)
|
||||
|
||||
async def handler(stream: trio.SocketStream) -> None:
|
||||
tcp_stream = TrioTCPStream(stream)
|
||||
await self.handler(tcp_stream)
|
||||
remote_host : str = ""
|
||||
remote_port : int = 0
|
||||
try:
|
||||
tcp_stream = TrioTCPStream(stream)
|
||||
remote_host,remote_port = tcp_stream.get_remote_address()
|
||||
await self.handler(tcp_stream)
|
||||
except Exception as e:
|
||||
logger.error(f"Connection from {remote_host}:{remote_port} failed.")
|
||||
|
||||
listeners = await nursery.start(
|
||||
serve_tcp,
|
||||
|
||||
Reference in New Issue
Block a user