From 857bb34f4e5a1ded58281a9bc0212927a4b241b5 Mon Sep 17 00:00:00 2001 From: mhchia Date: Tue, 4 Feb 2020 17:44:10 +0800 Subject: [PATCH] Add checkpoints in `PubsubNotifee` Since some of the methods in `PubsubNotifee` are doing nothing, add checkpoints to yield control. --- libp2p/pubsub/pubsub_notifee.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/pubsub/pubsub_notifee.py b/libp2p/pubsub/pubsub_notifee.py index 08b4a5b..b32c145 100644 --- a/libp2p/pubsub/pubsub_notifee.py +++ b/libp2p/pubsub/pubsub_notifee.py @@ -32,10 +32,10 @@ class PubsubNotifee(INotifee): self.dead_peers_queue = dead_peers_queue async def opened_stream(self, network: INetwork, stream: INetStream) -> None: - ... + await trio.hazmat.checkpoint() async def closed_stream(self, network: INetwork, stream: INetStream) -> None: - ... + await trio.hazmat.checkpoint() async def connected(self, network: INetwork, conn: INetConn) -> None: """ @@ -67,7 +67,7 @@ class PubsubNotifee(INotifee): ... async def listen(self, network: INetwork, multiaddr: Multiaddr) -> None: - ... + await trio.hazmat.checkpoint() async def listen_close(self, network: INetwork, multiaddr: Multiaddr) -> None: - ... + await trio.hazmat.checkpoint()