diff --git a/locust/main.py b/locust/main.py index 50cda37761..96f51d7a0f 100644 --- a/locust/main.py +++ b/locust/main.py @@ -433,8 +433,7 @@ def ensure_user_class_name(config): if options.run_time: if options.worker: - logger.error("--run-time should be specified on the master node, and not on worker nodes") - sys.exit(1) + logger.info("--run-time specified for a worker node will be ignored.") try: options.run_time = parse_timespan(options.run_time) except ValueError: diff --git a/locust/util/timespan.py b/locust/util/timespan.py index 7fdc607c4d..910ad89be4 100644 --- a/locust/util/timespan.py +++ b/locust/util/timespan.py @@ -2,7 +2,7 @@ from datetime import timedelta -def parse_timespan(time_str): +def parse_timespan(time_str) -> int: """ Parse a string representing a time span and return the number of seconds. Valid formats are: 20, 20s, 3m, 2h, 1h20m, 3h30m10s, etc. @@ -18,8 +18,7 @@ def parse_timespan(time_str): parts = timespan_regex.match(time_str) if not parts: raise ValueError("Invalid time span format. Valid formats: 20, 20s, 3m, 2h, 1h20m, 3h30m10s, etc.") - parts = parts.groupdict() - time_params = {name: int(value) for name, value in parts.items() if value} + time_params = {name: int(value) for name, value in parts.groupdict().items() if value} if not time_params: raise ValueError("Invalid time span format. Valid formats: 20, 20s, 3m, 2h, 1h20m, 3h30m10s, etc.") return int(timedelta(**time_params).total_seconds())