When using locust in distributed mode, is there an event that would allow the master node to detect whenever a new worker joins, and send it a message?
We currently use @events.test_start.add_listener as described in this snippet from the locust documentation
@events.test_start.add_listener
def on_test_start(environment, **_kwargs):
if not isinstance(environment.runner, WorkerRunner):
users = [
{"name": "User1"},
{"name": "User2"},
{"name": "User3"},
]
environment.runner.send_message('test_users', users)
However, this is only the "test_start" event. We're looking to cover cases where new workers join randomly afterwards.
Thanks
A worker_connect
event was added in locust 2.16.0!
https://github.com/locustio/locust/pull/2344
It is a little bit complicated to use though, because the worker may not be ready to receive any custom messages when it happens (the worker hasnt had a chance to trigger any other events, like init
).