五、locust -- 顺序执行 SequentialTaskSet
# *_*coding:utf-8 *_* # @Author : zyb import queue q = queue.Queue() for i in range(100): q.put(i) from locust import FastHttpUser, task, between, SequentialTaskSet class MySequentialTasks(SequentialTaskSet): @task def task_one(self): global ii ii = q.get() self.client.get("/LocustTest/",name='get') print('get',ii) @task def task_two(self): self.client.post("/LocustTest/",name='post') print('post',ii) class MySequentialUser(FastHttpUser): wait_time = between(1, 5) # 用户之间等待的时间范围 tasks = [MySequentialTasks] # 指定顺序任务集 if __name__ == '__main__': import os file_path = os.path.abspath(__file__) os.system(f"locust -f {file_path} --host=http://127.0.0.1:8000")