[Python] Getting request_before_redirect.url is None for POSTS requests in Locust Python

Discussão em 'Python' iniciado por Stack, Setembro 1, 2025.

  1. Stack

    Stack Membro Participativo

    Trying to use locust following the documentation, https://docs.locust.io/en/stable/quickstart.html

    from locust import HttpUser, task

    class TestUser(HttpUser):

    # @task(1)
    # def health(self):
    # self.client.get("/health")

    @task(2)
    def post_value(self):
    self.client.post(
    "/some/route",
    headers={
    "key1": "value1"
    },
    data={
    "data1": "value1",
    })


    GET requests are working fine. POST requests are throwing the below error in locust clients.py.

    File "/opt/anaconda3/envs/email_bot/lib/python3.12/site-packages/locust/clients.py", line 286, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/anaconda3/envs/email_bot/lib/python3.12/site-packages/locust/clients.py", line 196, in request
    url = request_before_redirect.url # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'url'


    Tried setting allow_redirects=True but still getting the same error. Not able to identify the root issue. Any pointers will be helpful.

    Continue reading...

Compartilhe esta Página