Skip to content

Commit

Permalink
Make all LocustRunners aware of their target user count, not just Mas…
Browse files Browse the repository at this point in the history
…terLocustRunner
  • Loading branch information
cyberw committed Apr 16, 2020
1 parent 042b092 commit 7b2d3fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, environment):
self.cpu_warning_emitted = False
self.greenlet.spawn(self.monitor_cpu).link_exception(greenlet_exception_handler)
self.exceptions = {}
self.target_user_count = None

# set up event listeners for recording requests
def on_request_success(request_type, name, response_time, response_length, **kwargs):
Expand Down Expand Up @@ -230,6 +231,7 @@ def start(self, locust_count, hatch_rate, wait=False):
self.exceptions = {}
self.cpu_warning_emitted = False
self.worker_cpu_warning_emitted = False
self.target_user_count = locust_count

# Dynamically changing the locust count
if self.state != STATE_INIT and self.state != STATE_STOPPED:
Expand Down Expand Up @@ -317,6 +319,7 @@ def on_locust_error(locust_instance, exception, tb):
self.environment.events.locust_error.add_listener(on_locust_error)

def start(self, locust_count, hatch_rate, wait=False):
self.target_user_count = locust_count
if hatch_rate > 100:
logger.warning("Your selected hatch rate is very high (>100), and this is known to sometimes cause issues. Do you really need to ramp up that fast?")

Expand Down Expand Up @@ -368,7 +371,6 @@ def __init__(self, environment, master_bind_host, master_bind_port):
"""
super().__init__(environment)
self.worker_cpu_warning_emitted = False
self.target_user_count = None
self.master_bind_host = master_bind_host
self.master_bind_port = master_bind_port

Expand Down Expand Up @@ -652,6 +654,7 @@ def worker(self):
self.client.send(Message("hatching", None, self.client_id))
job = msg.data
self.hatch_rate = job["hatch_rate"]
self.target_user_count = job["num_clients"]
self.environment.host = job["host"]
self.environment.stop_timeout = job["stop_timeout"]
if self.hatching_greenlet:
Expand Down

0 comments on commit 7b2d3fd

Please sign in to comment.