How to add custom sleep times to a test
By default, you should set your wait_time to handle "user timings" like reading the page, etc. However, you can have custom sleeps anywhere in the test should you need to.
The test below is wait for between 10 and 20 seconds for each task a client executes, but the task to load_page will also sleep between 10 and 60 seconds between its two get requests.
import random from random import randint from locust import HttpUser, TaskSet, task, between import time class AwesomeUser(HttpUser): wait_time = between(10, 20) @task(1) def load_page(self): self.client.get('/page1') # Sleep for 10 - 60 seconds time.sleep(random.randint(10, 60)) self.client.get('/page2')