Skip to content

Custom argument values didn't passed into a worker in distributed mode #3206

@ivan-krupin-magicmedia

Description

@ivan-krupin-magicmedia

Prerequisites

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions