Skip to content

Commit ec54d9e

Browse files
committed
Address the ci fail
1 parent 3d2752e commit ec54d9e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

libp2p/pubsub/pubsub.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
)
4242
from libp2p.io.exceptions import (
4343
IncompleteReadError,
44+
IOException,
45+
)
46+
from libp2p.network.connection.exceptions import (
47+
RawConnError,
4448
)
4549
from libp2p.network.exceptions import (
4650
SwarmException,
@@ -49,6 +53,7 @@
4953
StreamClosed,
5054
StreamEOF,
5155
StreamError,
56+
StreamReset,
5257
)
5358
from libp2p.peer.id import (
5459
ID,
@@ -318,6 +323,14 @@ async def continuously_read_stream(self, stream: INetStream) -> None:
318323
logger.debug(
319324
f"Stream closed for peer {peer_id}, exiting read loop cleanly."
320325
)
326+
except StreamError as e:
327+
# Socket closed during read - this is normal during shutdown
328+
logger.debug(
329+
f"Stream error for peer {peer_id} (normal during shutdown): {e}"
330+
)
331+
except (IOException, RawConnError) as e:
332+
# Connection closed - normal during teardown
333+
logger.debug(f"Connection closed for peer {peer_id} during read: {e}")
321334

322335
def set_topic_validator(
323336
self, topic: str, validator: ValidatorFn, is_async_validator: bool
@@ -870,7 +883,8 @@ async def write_msg(self, stream: INetStream, rpc_msg: rpc_pb2.RPC) -> bool:
870883
Write an RPC message to a stream with proper error handling.
871884
872885
Implements WriteMsg similar to go-msgio which is used in go-libp2p
873-
Ref: https://github.com/libp2p/go-msgio/blob/master/protoio/uvarint_writer.go#L56
886+
Ref: https://github.com/libp2p/go-msgio/blob/master/protoio/
887+
uvarint_writer.go#L56
874888
875889
876890
:param stream: stream to write the message to

0 commit comments

Comments
 (0)