Custom argument values didn't passed into a worker in distributed mode
Prerequisites
- [x] I am using the latest version of Locust
- [x] I am reporting a bug, not asking a question
Description
After starting both master and worker I'm opening webui on port 8089 and changing custom argument values there. As for me, I see default values, not the ones that I provided in webui.
Command line
locust --master --master-port 8089
Locustfile contents
from locust import constant, task, events
from locust.user.users import HttpUser
@events.init_command_line_parser.add_listener
def add_custom_arguments(parser):
# add arguments that we should see in GUI
parser.add_argument(
"--arg1",
type=str,
help="Some argument 1",
default="Foo",
)
parser.add_argument(
"--arg2",
type=int,
help=f"Some argument 2 (default: {10})",
default=10,
)
class MyUser1(HttpUser):
host = "http://example.com"
wait_time = constant(1)
@task
def get_ip(self):
print(
"pasred custom args: "
f"arg1={self.environment.parsed_options.arg1}, "
f"arg2={self.environment.parsed_options.arg2}"
)
Python version
3.12
Locust version
2.40.1
Operating system
WSL (Ubuntu)
@ivan-krupin-magicmedia I can work on this issue. Can I get it assigned as part of Hacktober fest 2025?
hey @cyberw @sanga @amandasaurus can you assign this to me I would like to work on it ?
#Hi @ivan-krupin-magicmedia @cyberw
I've create a PR, please review it. Thanks :)
#Hi @ivan-krupin-magicmedia @cyberw
I've create a PR, please review it. Thanks :)
@sonianuj287 Just checked your changes. The issue is not fixed. What did I do:
- fetched latest commit on master
- installed as env package via
pip install -e - Used the same script as I provided in that issue
- executed distributed test with commands:
master terminal: locust --master --master-port 8089
worker terminal: locust --worker --master-host localhost
- I see default values in webui as Foo and 10
- I changed values in that fields to Bar and 1024
- I started the test
- I see in worker's logs
pasred custom args: arg1=Foo, arg2=10
pasred custom args: arg1=Foo, arg2=10
pasred custom args: arg1=Foo, arg2=10
pasred custom args: arg1=Foo, arg2=10
Please, take a look into your test, I'm not sure that we can say for sure that if we see in webui page changed values in input fields then it's mean all is working.
Thank you for your effort!
And one more update:
Figured out that the issue here as argument naming - it's not allowed to use name like arg1, only arg-1 (superweird if you asks me).
I tried with that type of argument naming and everything works.
Moreover, I tried to revert fix from the mentioned PR and it even worked without that fix 😅
So I'm not sure what kind of bug exactly was fixed here.
Yea I'm not sure what was really fixed either. I'll probably revert the PR, unless @sonianuj287 comes up with an improved version in the next few days.
Reverted in https://github.com/locustio/locust/pull/3255
As far as I can tell, the test case introduced there passes without the relevant changes so I don't think it actually fixed anything.