Fix handler in net_stream_pair_factory
Change it to async function. It wasn't discovered since we caught all exceptions raised in stream handlers.
This commit is contained in:
parent
3a91f114ab
commit
7ae9de9002
|
@ -404,13 +404,18 @@ async def net_stream_pair_factory(
|
||||||
|
|
||||||
stream_1: INetStream
|
stream_1: INetStream
|
||||||
|
|
||||||
# Just a proxy, we only care about the stream
|
# Just a proxy, we only care about the stream.
|
||||||
def handler(stream: INetStream) -> None:
|
# Add a barrier to avoid stream being removed.
|
||||||
|
event_handler_finished = trio.Event()
|
||||||
|
|
||||||
|
async def handler(stream: INetStream) -> None:
|
||||||
nonlocal stream_1
|
nonlocal stream_1
|
||||||
stream_1 = stream
|
stream_1 = stream
|
||||||
|
await event_handler_finished.wait()
|
||||||
|
|
||||||
async with host_pair_factory(is_secure) as hosts:
|
async with host_pair_factory(is_secure) as hosts:
|
||||||
hosts[1].set_stream_handler(protocol_id, handler)
|
hosts[1].set_stream_handler(protocol_id, handler)
|
||||||
|
|
||||||
stream_0 = await hosts[0].new_stream(hosts[1].get_id(), [protocol_id])
|
stream_0 = await hosts[0].new_stream(hosts[1].get_id(), [protocol_id])
|
||||||
yield stream_0, stream_1
|
yield stream_0, stream_1
|
||||||
|
event_handler_finished.set()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user