Skip to content

Commit 16a16d1

Browse files
committed
Docs: make it more clear that requests wait for responses until moving to the next line of code.
1 parent 64d3bc5 commit 16a16d1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Diff for: docs/quickstart.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ A Locust test is essentially just a Python program making requests to the system
1616
self.client.get("/hello")
1717
self.client.get("/world")
1818
19-
This user will make HTTP requests to ``/hello``, and then ``/world``, again and again. For a full explanation and a more realistic example see :ref:`writing-a-locustfile`.
19+
This user will make an HTTP request to ``/hello``, and after that to ``/world``, and then repeat. For a full explanation and a more realistic example see :ref:`writing-a-locustfile`.
2020

2121
Change ``/hello`` and ``/world`` to some actual paths on the web site/service you want to test, put the code in a file named ``locustfile.py`` in your current directory and then run ``locust``:
2222

2323
.. code-block:: console
2424
:substitutions:
2525
2626
$ locust
27-
[2021-07-24 09:58:46,215] .../INFO/locust.main: Starting web interface at http://*:8089
27+
[2021-07-24 09:58:46,215] .../INFO/locust.main: Starting web interface at http://0.0.0.0:8089
2828
[2021-07-24 09:58:46,285] .../INFO/locust.main: Starting Locust |version|
2929
3030
Locust's web interface

Diff for: docs/writing-a-locustfile.rst

+11-9
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,30 @@ is executed. For more info see :ref:`wait-time`.
6262
6363
@task
6464
def hello_world(self):
65-
...
65+
self.client.get("/hello")
66+
self.client.get("/world")
6667
67-
Methods decorated with ``@task`` are the core of your locust file. For every running user,
68-
Locust creates a greenlet (micro-thread), that will call those methods.
68+
Methods decorated with ``@task`` are the core of your locust file. For every running User,
69+
Locust creates a `greenlet <https://greenlet.readthedocs.io/en/stable/greenlet.html>`_ (a coroutine or "micro-thread"), that will call those methods.
70+
Code within a task is executed sequentially (it is just regular Python code),
71+
so ``/world`` wont be called until the response from ``/hello`` has been received.
6972

7073
.. code-block:: python
7174
7275
@task
7376
def hello_world(self):
74-
self.client.get("/hello")
75-
self.client.get("/world")
76-
77+
...
78+
7779
@task(3)
7880
def view_items(self):
79-
...
81+
...
8082
8183
We've declared two tasks by decorating two methods with ``@task``, one of which has been given a higher weight (3).
8284
When our ``QuickstartUser`` runs it'll pick one of the declared tasks - in this case either ``hello_world`` or
8385
``view_items`` - and execute it. Tasks are picked at random, but you can give them different weighting. The above
8486
configuration will make Locust three times more likely to pick ``view_items`` than ``hello_world``. When a task has
85-
finished executing, the User will then sleep during its wait time (in this case between 1 and 5 seconds).
86-
After its wait time it'll pick a new task and keep repeating that.
87+
finished executing, the User will then sleep for its specified wait time (in this case between 1 and 5 seconds).
88+
Then it will pick a new task.
8789

8890
Note that only methods decorated with ``@task`` will be picked, so you can define your own internal helper methods any way you like.
8991

0 commit comments

Comments
 (0)