0

I have been working on Locust lately, I wanted to know if we can manage the user timings for each user or a set of users maybe. for example, how can I replicate a user being on for a certain amount of time and then killing the user. I am not sure how we can handle this.

VKr
  • 3
  • 4

1 Answers1

0

From the documentation:

In addition to the task_set attribute, one usually wants to declare the min_wait and max_wait attributes. These are the minimum and maximum time respectively, in milliseconds, that a simulated user will wait between executing each task. min_wait and max_wait default to 1000, and therefore a locust will always wait 1 second between each task if min_wait and max_wait are not declared.

With the following locustfile, each user would wait between 5 and 15 seconds between tasks:

from locust import Locust, TaskSet, task

class MyTaskSet(TaskSet):
    @task
    def my_task(self):
        print "executing my_task"

class MyLocust(Locust):
    task_set = MyTaskSet
    min_wait = 5000
    max_wait = 15000

The min_wait and max_wait attributes can also be overridden in a TaskSet class.

J. Blackadar
  • 1,821
  • 1
  • 11
  • 18
  • My question is, can you control how long a particular user instance can be on and kill it when I want to? Say maybe like, – VKr Aug 21 '18 at 21:28