locust-cloud 1.0.4__py3-none-any.whl → 1.0.6__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_cloud/__init__.py CHANGED
@@ -6,8 +6,6 @@ import os
6
6
  from locust import events
7
7
  from locust.argument_parser import LocustArgumentParser
8
8
 
9
- os.environ["LOCUST_BUILD_PATH"] = os.path.join(os.path.dirname(__file__), "webui/dist")
10
- os.environ["LOCUST_WEB_LOGIN"] = "1"
11
9
  PG_USER = os.environ.get("PG_USER")
12
10
  PG_HOST = os.environ.get("PG_HOST")
13
11
  PG_PASSWORD = os.environ.get("PG_PASSWORD")
@@ -40,6 +38,8 @@ def add_arguments(parser: LocustArgumentParser):
40
38
 
41
39
  @events.init.add_listener
42
40
  def on_locust_init(environment, **args):
41
+ os.environ["LOCUST_BUILD_PATH"] = os.path.join(os.path.dirname(__file__), "webui/dist")
42
+
43
43
  if environment.parsed_options.exporter:
44
44
  Timescale(
45
45
  environment,
@@ -25,7 +25,7 @@ def safe_serialize(obj):
25
25
  class Timescale:
26
26
  def __init__(self, environment: locust.env.Environment, pg_user, pg_host, pg_password, pg_database, pg_port):
27
27
  self.env = environment
28
- self._run_id = ""
28
+ self._run_id = None
29
29
  self._samples: list[dict] = []
30
30
  self._background = gevent.spawn(self._run)
31
31
  self._hostname = socket.gethostname()
@@ -75,7 +75,7 @@ class Timescale:
75
75
 
76
76
  def on_test_start(self, environment: locust.env.Environment):
77
77
  if not self.env.parsed_options or not self.env.parsed_options.worker:
78
- environment._run_id = datetime.now(UTC) # type: ignore
78
+ self._run_id = environment._run_id = datetime.now(UTC) # type: ignore
79
79
  msg = environment._run_id.strftime("%Y-%m-%d, %H:%M:%S.%f") # type: ignore
80
80
  if environment.runner is not None:
81
81
  logging.debug(f"about to send run_id to workers: {msg}")