-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TaskSet min_wait and max_wait are ignored #891
Comments
Ah, good catch, looks like Line 320 in 30275af
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! |
I just found the same problem. I ended up just creating a TaskSet mixin that set it on all my tasksets, but it would be nice to be able to inherit from the locust's wait_function and have it still use the taskset's I think python has the ability to rebind |
I just hit this problem, as well. I'm not clear on the workaround... can anyone provide more direction? |
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? |
Oh, this should definitely be fixed. Nice debugging. I didn't realise that lambda functions also became bound methods when declared within a class definition. Here's a simple (currently failing) test for this: def test_different_wait_times_on_locust_and_taskset(self):
class MyTaskSet(TaskSet):
min_wait = 1
max_wait = 1
class MyLocust(Locust):
min_wait = 200
max_wait = 200
taskset = MyTaskSet(MyLocust())
self.assertEqual(0.001, taskset.get_wait_secs()) |
this is fixed now, right @heyman ? |
Yes it it! |
Description of issue / feature request
min_wait
/max_wait
overrides inTaskSet
class not working correctly. When settingmin_wait
andmax_wait
values in aTaskSet
class, the values seem to be ignored and the default values of 1000 (from theLocust
class) are used instead.I've done some digging into this and I think I know where the problem lies. The
TaskSet
'swait_function
is automatically set to the locust'swait_function
if undefined, but the locust'swait_function
was defined as a lambda using its ownmin_wait
andmax_wait
values. As such, theTaskSet
'smin_wait
andmax_wait
value have no effect.You can get around this by assigning a new lambda
wait_function
to theTaskSet
, but this defeats the purpose of being able to override themin_wait
andmax_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)
Steps to reproduce (for bug reports)
The text was updated successfully, but these errors were encountered: