Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locust spams error if Host is invalid #2575

Closed
2 tasks done
viktorfreiman opened this issue Feb 1, 2024 · 3 comments
Closed
2 tasks done

Locust spams error if Host is invalid #2575

viktorfreiman opened this issue Feb 1, 2024 · 3 comments
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it

Comments

@viktorfreiman
Copy link

viktorfreiman commented Feb 1, 2024

Prerequisites

Description

When I tried the the hello world exemple I thought that Locust would try adding the missing scheme for the host.
What I found was that locust tries to launch the user as fast as posible and just spams the printout.

As you can see it loops as fast as possible. I tried to look after a similar issue but I did not found anything.
Wouldn't that be good to have a better error exit then spam looping when something core like the host is wrong.

[2024-02-01 09:30:54,511] d189d6727fd5/ERROR/locust.user.task: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 342, in run
    self.execute_next_task()
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 375, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 492, in execute_task
    task(self.user)
  File "/workspaces/popins-v3/locustfiles/demo.py", line 8, in hello_world
    self.client.get("/hello")
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 136, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 181, in _send_request_safe_mode
    return super().request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?

[2024-02-01 09:30:54,512] d189d6727fd5/ERROR/locust.user.task: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 342, in run
    self.execute_next_task()
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 375, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 492, in execute_task
    task(self.user)
  File "/workspaces/popins-v3/locustfiles/demo.py", line 8, in hello_world
    self.client.get("/hello")
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 136, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 181, in _send_request_safe_mode
    return super().request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?

[2024-02-01 09:30:54,513] d189d6727fd5/ERROR/locust.user.task: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 342, in run
    self.execute_next_task()
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 375, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 492, in execute_task
    task(self.user)
  File "/workspaces/popins-v3/locustfiles/demo.py", line 8, in hello_world
    self.client.get("/hello")
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 136, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 181, in _send_request_safe_mode
    return super().request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?

[2024-02-01 09:30:54,514] d189d6727fd5/ERROR/locust.user.task: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 342, in run
    self.execute_next_task()
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 375, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 492, in execute_task
    task(self.user)
  File "/workspaces/popins-v3/locustfiles/demo.py", line 8, in hello_world
    self.client.get("/hello")
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 136, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 181, in _send_request_safe_mode
    return super().request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?

[2024-02-01 09:30:54,515] d189d6727fd5/ERROR/locust.user.task: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 342, in run
    self.execute_next_task()
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 375, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/user/task.py", line 492, in execute_task
    task(self.user)
  File "/workspaces/popins-v3/locustfiles/demo.py", line 8, in hello_world
    self.client.get("/hello")
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 136, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/locust/clients.py", line 181, in _send_request_safe_mode
    return super().request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/vscode/.local/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'localhost/hello': No scheme supplied. Perhaps you meant https://localhost/hello?

Command line

locust -f demo.py --headless --users 1 --spawn-rate -1 -H localhost

Locustfile contents

from locust import HttpUser, task

class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("/hello")
        self.client.get("/world")

Python version

3.11.4

Locust version

2.21.0

Operating system

Debian 11

@cyberw
Copy link
Collaborator

cyberw commented Feb 1, 2024

Agreed, that sucks. Might not have time to look at it soon, but PRs welcome.

Copy link

github-actions bot commented Apr 2, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it label Apr 2, 2024
Copy link

This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it
Projects
None yet
2 participants