You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would make sense to allow interrupt()-ing from inside the on_start method.
This would allow a TaskSet for, say, updating 'widgets' where the on_start gets a list of widgets, then tasks within the TaskSet perform various updates to the widgets. However, in the case where there are no widgets yet, the TaskSet would be interrupt()-ed.
I was hoping to be able to do something like this:
class WidgetTasks(locust.TaskSet):
def on_start(self):
r = self.client.get("/widgets")
self.widgets = r.json["widgets"]
if not self.widgets:
# there are no widgets to update, so jump out of this TaskSet
self.interrupt()
@locust.task
def update_widget_name(self):
widget = random.choice(self.widgets)
self.client.put(
"/widgets/{0}/name".format(widget["id"]),
data="New Name")
# etc...
class UserTasks(locust.TaskSet):
tasks = {WidgetTasks: 1}
@locust.task
def create_widget(self):
self.client.post("/widgets")
# etc...
I hope this make sense?
I think it would just be a case of lifting this except block out into another try block that wrapped the call to on_start and the while loop? I'd submit a pull request myself, but I haven't been able to get the unit tests to run.
The text was updated successfully, but these errors were encountered:
I initially wasn't sure how to run the tests, and then didn't spend enough time installing the dependencies. But python -m unittest discover seems to work now that I've installed python-msgpack and mock.
I do still occasionally get this failure though:
======================================================================
FAIL: test_moving_average_100 (locust.test.test_average.MovingAverageTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/joe/Projects/Public/locust/locust/test/test_average.py", line 58, in test_moving_average_100
self._assertion(taskset, deviation, max_deviation, percentage)
File "/Users/joe/Projects/Public/locust/locust/test/test_average.py", line 45, in _assertion
self.assertTrue(deviation < max_deviation, msg="Deviation not within %s%% of wanted average" % percentage)
AssertionError: Deviation not within 5.0% of wanted average
I think it would make sense to allow
interrupt()
-ing from inside theon_start
method.This would allow a
TaskSet
for, say, updating 'widgets' where theon_start
gets a list of widgets, then tasks within theTaskSet
perform various updates to the widgets. However, in the case where there are no widgets yet, theTaskSet
would beinterrupt()
-ed.I was hoping to be able to do something like this:
I hope this make sense?
I think it would just be a case of lifting this
except
block out into anothertry
block that wrapped the call toon_start
and thewhile
loop? I'd submit a pull request myself, but I haven't been able to get the unit tests to run.The text was updated successfully, but these errors were encountered: