Skip to content

Commit ad0b550

Browse files
committed
make limit configurable in push_identify_to_peers
1 parent cbe2b4b commit ad0b550

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libp2p/identity/identify_push/identify_push.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
PROTOCOL_VERSION = "ipfs/0.1.0"
4242
AGENT_VERSION = get_agent_version()
4343
CONCURRENCY_LIMIT = 10
44-
LIMIT = trio.Semaphore(CONCURRENCY_LIMIT)
4544

4645

4746
def identify_push_handler_for(host: IHost) -> StreamHandlerFn:
@@ -134,7 +133,10 @@ async def _update_peerstore_from_identify(
134133

135134

136135
async def push_identify_to_peer(
137-
host: IHost, peer_id: ID, observed_multiaddr: Multiaddr | None = None
136+
host: IHost,
137+
peer_id: ID,
138+
observed_multiaddr: Multiaddr | None = None,
139+
limit=trio.Semaphore(CONCURRENCY_LIMIT),
138140
) -> bool:
139141
"""
140142
Push an identify message to a specific peer.
@@ -148,7 +150,7 @@ async def push_identify_to_peer(
148150
True if the push was successful, False otherwise.
149151
150152
"""
151-
async with LIMIT:
153+
async with limit:
152154
try:
153155
# Create a new stream to the peer using the identify/push protocol
154156
stream = await host.new_stream(peer_id, [ID_PUSH])

0 commit comments

Comments
 (0)