mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 22:50:54 +00:00
SwarmConn: don't access Swarm.manager
Open a local nursery instead.
This commit is contained in:
@ -56,13 +56,14 @@ class SwarmConn(INetConn):
|
|||||||
|
|
||||||
async def _handle_new_streams(self) -> None:
|
async def _handle_new_streams(self) -> None:
|
||||||
self.event_started.set()
|
self.event_started.set()
|
||||||
while True:
|
async with trio.open_nursery() as nursery:
|
||||||
try:
|
while True:
|
||||||
stream = await self.muxed_conn.accept_stream()
|
try:
|
||||||
except MuxedConnUnavailable:
|
stream = await self.muxed_conn.accept_stream()
|
||||||
break
|
except MuxedConnUnavailable:
|
||||||
# Asynchronously handle the accepted stream, to avoid blocking the next stream.
|
break
|
||||||
self.swarm.manager.run_task(self._handle_muxed_stream, stream)
|
# Asynchronously handle the accepted stream, to avoid blocking the next stream.
|
||||||
|
nursery.start_soon(self._handle_muxed_stream, stream)
|
||||||
|
|
||||||
await self.close()
|
await self.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user