From 4180bf53f7e01b6fcf1cb19192352f1e5e0fb062 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Fri, 27 Feb 2026 16:22:56 +0100 Subject: [PATCH] Add timeout flag and allow for flags using make_pretty.sh Using "make_pretty.sh -j 1 -t 2" is often more likely to work than increasing the (hardwired) timeout value --- make_pretty.sh | 2 +- tools/precommit/precommit.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/make_pretty.sh b/make_pretty.sh index a31b007b33..d228a31a68 100755 --- a/make_pretty.sh +++ b/make_pretty.sh @@ -2,6 +2,6 @@ CP2K_ROOT=$(dirname "$0") -"${CP2K_ROOT}/tools/precommit/precommit.py" --allow-modifications +"${CP2K_ROOT}/tools/precommit/precommit.py" --allow-modifications "$@" #EOF diff --git a/tools/precommit/precommit.py b/tools/precommit/precommit.py index 0fe0a19139..03e5158051 100755 --- a/tools/precommit/precommit.py +++ b/tools/precommit/precommit.py @@ -59,13 +59,22 @@ def main() -> None: default=1, help="number seconds in between progressbar updates", ) + parser.add_argument( + "-t", + "--timeout", + type=int, + default=10, + help="Server wait timeout in seconds", + ) parser.add_argument("files", metavar="FILE", nargs="*", help="files to process") args = parser.parse_args() print( # Say hello to the server. - f"Running precommit checks using {args.num_workers} workers and server: {SERVER}" + f"Running precommit checks using {args.num_workers} workers and server: {SERVER} (server wait timeout: {args.timeout} seconds)" + ) + server_hello = ( + urlopen(Request(SERVER + "/"), timeout=args.timeout).read().decode("utf8") ) - server_hello = urlopen(Request(SERVER + "/"), timeout=10).read().decode("utf8") assert server_hello.startswith("cp2k precommit server") # Store candidate before changing base directory and creating scratch dir.