You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Locust任务完成后立即执行新任务而非固定等待时长?

Locust 取消任务间等待的实现方法

Locust完全支持你的需求,不需要必须设置固定wait_time。你可以通过两种方式实现任务完成后立即执行下一个dosomething任务:

  1. 设置等待时间为0
    直接将wait_time指定为constant(0),这样任务执行完毕后会立刻启动下一次任务:

    from locust import HttpUser, task, constant
    
    class MyUser(HttpUser):
        wait_time = constant(0)
    
        @task
        def dosomething(self):
            self.client.get("/doing")
    
  2. 移除wait_time属性
    如果不定义wait_time,Locust默认不会在任务之间添加等待,同样能达到立即执行下一个任务的效果:

    from locust import HttpUser, task
    
    class MyUser(HttpUser):
        @task
        def dosomething(self):
            self.client.get("/doing")
    

内容的提问来源于stack exchange,提问作者bavo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 20:20:17