locust
locust copied to clipboard
Locust spams error if Host is invalid
Prerequisites
- [X] I am using the latest version of Locust
- [X] I am reporting a bug, not asking a question
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
Agreed, that sucks. Might not have time to look at it soon, but PRs welcome.
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.
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!