Locust: stop_timeout defined in Locust class takes precedence over --run-time option

Created on 22 Oct 2019  路  3Comments  路  Source: locustio/locust

Describe the bug

stop_timeout defined in Locust class takes precedence over --run-time option.

Expected behavior

To my mind --run-time should take precedence over stop_timeout.

Actual behavior

ditto

Steps to reproduce

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

Environment settings

  • OS: Linux 5.3.6
  • Python version: 3.7.4
  • Locust version: 0.11.0
bug

Most helpful comment

Old code removed in 4e42d46edff59350b1a36861d9d8a53ef108a5a4.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

radiantone picture radiantone  路  3Comments

ghost picture ghost  路  3Comments

meeech picture meeech  路  4Comments

ludo550 picture ludo550  路  3Comments

bgenchel picture bgenchel  路  3Comments