locust 2.37.1.dev2__py3-none-any.whl → 2.37.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
locust/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.37.1.dev2'
21
- __version_tuple__ = version_tuple = (2, 37, 1, 'dev2')
20
+ __version__ = version = '2.37.2'
21
+ __version_tuple__ = version_tuple = (2, 37, 2)
locust/argument_parser.py CHANGED
@@ -773,12 +773,6 @@ Typically ONLY these options (and --locustfile) need to be specified on workers,
773
773
  action="store_true",
774
774
  help="Prints the final stats in JSON format to stdout. Useful for parsing the results in other programs/scripts. Use together with --headless and --skip-log for an output only with the json data.",
775
775
  )
776
- stats_group.add_argument(
777
- "--json-file",
778
- metavar="<filename>",
779
- dest="json_file",
780
- help="Prints the final stats in JSON format to file path specified.",
781
- )
782
776
 
783
777
  log_group = parser.add_argument_group("Logging options")
784
778
  log_group.add_argument(
locust/input_events.py CHANGED
@@ -99,9 +99,8 @@ def input_listener(key_to_func_map: dict[str, Callable]):
99
99
  def input_listener_func():
100
100
  try:
101
101
  poller = get_poller()
102
- except InitError:
103
- # This is a bit chatty, even for debug. Uncomment it if you're having problems with keyboard events
104
- # logging.debug(e)
102
+ except InitError as e:
103
+ logging.debug(e)
105
104
  return
106
105
 
107
106
  try:
locust/main.py CHANGED
@@ -640,8 +640,6 @@ See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-numb
640
640
  runner.quit()
641
641
  if options.json:
642
642
  stats.print_stats_json(runner.stats)
643
- if options.json_file:
644
- stats.save_stats_json(runner.stats, options.json_file)
645
643
  elif not isinstance(runner, locust.runners.WorkerRunner):
646
644
  stats.print_stats(runner.stats, current=False)
647
645
  stats.print_percentile_stats(runner.stats)
locust/stats.py CHANGED
@@ -820,11 +820,6 @@ def print_stats_json(stats: RequestStats) -> None:
820
820
  print(json.dumps(stats.serialize_stats(), indent=4))
821
821
 
822
822
 
823
- def save_stats_json(stats: RequestStats, filename: str) -> None:
824
- with open(f"{filename}.json", "w") as _:
825
- json.dumps(stats.serialize_stats(), indent=4)
826
-
827
-
828
823
  def get_stats_summary(stats: RequestStats, current=True) -> list[str]:
829
824
  """
830
825
  stats summary will be returned as list of string
locust/web.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import csv
4
+ import itertools
4
5
  import json
5
6
  import logging
6
7
  import mimetypes
@@ -8,7 +9,6 @@ import os.path
8
9
  from functools import wraps
9
10
  from html import escape
10
11
  from io import StringIO
11
- from itertools import chain
12
12
  from json import dumps
13
13
  from typing import TYPE_CHECKING, Any, TypedDict
14
14
 
@@ -456,18 +456,17 @@ class WebUI:
456
456
 
457
457
  return jsonify(report)
458
458
 
459
- for s in chain(stats.sort_stats(environment.runner.stats.entries), [environment.runner.stats.total]):
460
- _stats.append(s.to_dict())
461
-
462
- errors = [e.serialize() for e in environment.runner.errors.values()]
463
-
464
459
  # Truncate the total number of stats and errors displayed since a large number of rows will cause the app
465
460
  # to render extremely slowly. Aggregate stats should be preserved.
466
- truncated_stats = _stats[:500]
467
- if len(_stats) > 500:
468
- truncated_stats += [_stats[-1]]
461
+ _stats.extend(
462
+ stat.to_dict() for stat in itertools.islice(stats.sort_stats(environment.runner.stats.entries), 500)
463
+ )
464
+ _stats.append(environment.runner.stats.total.to_dict())
465
+
466
+ errors = [e.serialize() for e in itertools.islice(environment.runner.errors.values(), 500)]
467
+
468
+ report = {"stats": _stats, "errors": errors}
469
469
 
470
- report = {"stats": truncated_stats, "errors": errors[:500]}
471
470
  total_stats = _stats[-1]
472
471
 
473
472
  if _stats:
@@ -495,6 +494,7 @@ class WebUI:
495
494
  )
496
495
 
497
496
  report["workers"] = workers
497
+ report["worker_count"] = environment.runner.worker_count
498
498
 
499
499
  report["state"] = environment.runner.state
500
500
  report["user_count"] = environment.runner.user_count
@@ -564,6 +564,7 @@ class WebUI:
564
564
  )
565
565
 
566
566
  @app_blueprint.route("/user", methods=["POST"])
567
+ @self.auth_required_if_enabled
567
568
  def update_user():
568
569
  assert request.method == "POST"
569
570
 
@@ -572,6 +573,15 @@ class WebUI:
572
573
 
573
574
  return {}, 201
574
575
 
576
+ @app_blueprint.route("/worker-count")
577
+ @self.auth_required_if_enabled
578
+ def get_worker_count():
579
+ return {
580
+ "worker_count": self.environment.runner.worker_count
581
+ if isinstance(self.environment.runner, MasterRunner)
582
+ else 0
583
+ }
584
+
575
585
  app.register_blueprint(app_blueprint)
576
586
 
577
587
  @property