Skip to content

Commit

Permalink
Example had inconsistent labeling
Browse files Browse the repository at this point in the history
The example inconsistently labeled worker and master in the comments and/or registered the wrong messages to the wrong runners.
  • Loading branch information
aathan authored Aug 20, 2022
1 parent 15bb045 commit ff30c7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/running-distributed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@ order to coordinate data. This can be easily accomplished with custom messages u
from locust import events
from locust.runners import MasterRunner, WorkerRunner
# Fired when the worker receives a message of type 'test_users'
# Fired when the master receives a message of type 'test_users'
def setup_test_users(environment, msg, **kwargs):
for user in msg.data:
print(f"User {user['name']} received")
environment.runner.send_message('acknowledge_users', f"Thanks for the {len(msg.data)} users!")
# Fired when the master receives a message of type 'acknowledge_users'
# Fired when the worker receives a message of type 'acknowledge_users'
def on_acknowledge(msg, **kwargs):
print(msg.data)
@events.init.add_listener
def on_locust_init(environment, **_kwargs):
if not isinstance(environment.runner, MasterRunner):
if isinstance(environment.runner, MasterRunner):
environment.runner.register_message('test_users', setup_test_users)
if not isinstance(environment.runner, WorkerRunner):
if isinstance(environment.runner, WorkerRunner):
environment.runner.register_message('acknowledge_users', on_acknowledge)
@events.test_start.add_listener
Expand Down

0 comments on commit ff30c7f

Please sign in to comment.