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
This commit is contained in:
Matthias Krack 2026-02-27 16:22:56 +01:00
parent 70b5527ee6
commit 4180bf53f7
2 changed files with 12 additions and 3 deletions

View file

@ -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

View file

@ -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.