Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/custom_messages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from locust import HttpUser, between, events, task
from locust.runners import MasterRunner, WorkerRunner
from locust.runners import LocalRunner, MasterRunner, WorkerRunner

import gevent

Expand Down Expand Up @@ -44,8 +44,12 @@ def on_test_start(environment, **_kwargs):

worker_count = environment.runner.worker_count
chunk_size = int(len(users) / worker_count)
if isinstance(environment.runner, LocalRunner):
workers = [environment.runner]
else:
workers = [environment.runner.clients]

for i, worker in enumerate(environment.runner.clients):
for i, worker in enumerate(workers):
start_index = i * chunk_size

if i + 1 < worker_count:
Expand Down
1 change: 1 addition & 0 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def __init__(self, environment) -> None:
# but it makes it easier to write tests that work for both local and distributed runs
self.worker_index = 0
self.client_id = socket.gethostname() + "_" + uuid4().hex
self.worker_count = 1
# Only when running in standalone mode (non-distributed)
self._local_worker_node = WorkerNode(id="local")
self._local_worker_node.user_classes_count = self.user_classes_count
Expand Down