question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TaskSet min_wait and max_wait are ignored

See original GitHub issue

Description of issue / feature request

min_wait / max_wait overrides in TaskSet class not working correctly. When setting min_wait and max_wait values in a TaskSet class, the values seem to be ignored and the default values of 1000 (from the Locust class) are used instead.

I’ve done some digging into this and I think I know where the problem lies. The TaskSet’s wait_function is automatically set to the locust’s wait_function if undefined, but the locust’s wait_function was defined as a lambda using its own min_wait and max_wait values. As such, the TaskSet’s min_wait and max_wait value have no effect.

You can get around this by assigning a new lambdawait_function to the TaskSet, but this defeats the purpose of being able to override the min_wait and max_wait values.

Expected behavior

When setting a min_wait and max_wait value of 10000 in a TaskSet class, tasks for each Locust should be spawned 10 seconds apart

Actual behavior

When setting a min_wait and max_wait value of 10000 in a TaskSet class, tasks for each Locust are still spawned 1 second apart (which is the default value)

Environment settings (for bug reports)

  • OS: Alpine Linux (docker image)
  • Python version: 2.7
  • Locust version: 0.9.0

Steps to reproduce (for bug reports)

  • Create a TaskSet class which inherits from the base TaskSet, with a min_value and max_value of 10000
  • Create a single task on the TaskSet class
  • Create a Locust class which inherits from the base HttpLocust, with its task_set property set to the TaskSet class created in step one
  • Start swarming with 1 user. You would expect the task to spawn every 10 seconds, but it spawns every 1 second.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stevecjcommented, Sep 4, 2019

I also seem to be experiencing the problem. If that MR fixes the issue, then can we have it merged and included in a release?

1reaction
aldenpeterson-wfcommented, Oct 10, 2018

Ah, good catch, looks like https://github.com/locustio/locust/blob/30275af9f2acd7f01a5ea04382610b4f3c2f7daa/locust/core.py#L320 should also be:

lambda self: random.randint(self.min_wait,self.max_wait)

in both the TaskSet as well as Locust.

@cgoldberg @heyman @mbeacom anyone have thoughts on this? Fixing it will change behavior for anyone who has defined TaskSet min/max. I’m unsure if this is enough of an issue to warrant not fixing this though.

Nice bug writeup too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

LocustIO: min_wait and max_wait not being applied
10.002 -- request 3 started. etc. This is because the wait time only happens between requests. It is not saying "run ever 1...
Read more >
Writing a locustfile — Locust 0.7.0 documentation
What happens then is that each TaskSet will pick one of it's tasks and call it. It will then wait a number of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found