stop_timeout defined in Locust class takes precedence over --run-time option.
To my mind --run-time should take precedence over stop_timeout.
ditto
Create a simple Locust class with stop_timeout defined:
locustfile.py:
from locust import HttpLocust, TaskSet, task
class SUTTasks(TaskSet):
@task
def landing_page(self):
self.client.get("/")
class SUT(HttpLocust):
stop_timeout = 10
task_set = SUTTasks
host = "https://www.google.com/"
Run the test with --run-time longer than stop_timeout, e.g. 20s:
locust --only-summary --no-web --run-time=20s
Then the test will stop after 10s not after 20s as defined by --run-time:
Check the timestamps in the log below:
[2019-10-22 10:31:32,645] local/INFO/locust.runners: All locusts hatched: SUT: 1
[2019-10-22 10:31:42,570] local/INFO/locust.runners: All locusts dead
[2019-10-22 10:31:42,571] local/INFO/locust.main: Shutting down (exit code 0), bye
Don't use Locust.stop_timeout. It should be removed from the code base (I wasn't actually aware
it was still around). As far as I can tell It's not documented anywhere so it shouldn't be considered as part of the official API. The time limit mechanism in the current implementation schedules a greenlet - which issues a call to locust_runner.quit() - at the specified time. It does not depend on the individual locust users ending their run loop.
Since I discovered it I'm not using it any more :)
Old code removed in 4e42d46edff59350b1a36861d9d8a53ef108a5a4.
Most helpful comment
Old code removed in 4e42d46edff59350b1a36861d9d8a53ef108a5a4.