DEFAULT_NEGOTIATE_TIMEOUT configurable

This commit is contained in:
lla-dane
2025-06-28 08:52:52 +05:30
parent d0e73f5438
commit 715e528a56
2 changed files with 16 additions and 6 deletions

View File

@ -50,7 +50,9 @@ class Multiselect(IMultiselectMuxer):
# FIXME: Make TProtocol Optional[TProtocol] to keep types consistent
async def negotiate(
self, communicator: IMultiselectCommunicator
self,
communicator: IMultiselectCommunicator,
negotiate_timeout: int = DEFAULT_NEGOTIATE_TIMEOUT,
) -> tuple[TProtocol, StreamHandlerFn | None]:
"""
Negotiate performs protocol selection.
@ -60,7 +62,7 @@ class Multiselect(IMultiselectMuxer):
:raise MultiselectError: raised when negotiation failed
"""
try:
with trio.fail_after(DEFAULT_NEGOTIATE_TIMEOUT):
with trio.fail_after(negotiate_timeout):
await self.handshake(communicator)
while True: