From 2c0693821fb4bdb9ae23159763d9f09e6b081669 Mon Sep 17 00:00:00 2001 From: Yannik Enss Date: Fri, 28 May 2021 13:29:25 +0200 Subject: [PATCH] add timeout --- check_factorio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_factorio.py b/check_factorio.py index 4ebc567..da4b8e9 100755 --- a/check_factorio.py +++ b/check_factorio.py @@ -48,6 +48,7 @@ def version_to_string(version): def query_server(host, port=34197): global info s = socket.socket(type=socket.SOCK_DGRAM) + s.settimeout(5) s.sendto(bytes.fromhex("30"), (host, port)) info = s.recvfrom(512)[0] @@ -80,7 +81,7 @@ if __name__ == "__main__": try: query_server(args.host, args.port) except Exception as e: - print(f"CRITICAL:{e}") + print(f"CRITICAL: {e}") exit(2) s = decode_packet()