From 6bb56e2fe80d551317881b5eb020f944ab83d49f Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Sun, 26 Nov 2023 12:05:50 +0100 Subject: [PATCH] Support timeout in rsync RCON --- rcon/source/async_rcon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rcon/source/async_rcon.py b/rcon/source/async_rcon.py index a012f0f..160356c 100644 --- a/rcon/source/async_rcon.py +++ b/rcon/source/async_rcon.py @@ -1,6 +1,6 @@ """Asynchronous RCON.""" -from asyncio import StreamReader, StreamWriter, open_connection +from asyncio import StreamReader, StreamWriter, open_connection, wait_for from rcon.exceptions import SessionTimeout, WrongPassword from rcon.source.proto import Packet, Type @@ -51,10 +51,11 @@ async def rcon( encoding: str = "utf-8", frag_threshold: int = 4096, frag_detect_cmd: str = "", + timeout: int | None, ) -> str: """Run a command asynchronously.""" - reader, writer = await open_connection(host, port) + reader, writer = await wait_for(open_connection(host, port), timeout=timeout) response = await communicate( reader, writer,