Locust 如何在所有用户完成任务后停止蝗虫负载测试?

Locust 如何在所有用户完成任务后停止蝗虫负载测试?,locust,Locust,在蝗虫文档中,我们只能使用self.interrupt()停止任务,但它将移动到父类。它不会停止负载测试。我想在所有用户登录并完成任务后停止完成负载测试 蝗虫版:1.1 class RegisteredUser(用户): @任务 课堂论坛(任务集): @任务(5) def view_螺纹(自): 通过 @任务(1) def停止(自): self.interrupt() @任务 def frontpage(自我): 通过 您可以调用self.environment.runner.quit()停止整

在蝗虫文档中,我们只能使用self.interrupt()停止任务,但它将移动到父类。它不会停止负载测试。我想在所有用户登录并完成任务后停止完成负载测试

蝗虫版:1.1

class RegisteredUser(用户):
@任务
课堂论坛(任务集):
@任务(5)
def view_螺纹(自):
通过
@任务(1)
def停止(自):
self.interrupt()
@任务
def frontpage(自我):
通过

您可以调用
self.environment.runner.quit()
停止整个运行


更多信息:

我的框架为每个用户创建凭证和支持变量的元组列表。我已将所有用户凭据、令牌、支持文件名等存储在这些元组中,作为列表的一部分。(实际上,这是在启动蝗虫之前自动完成的)

我将该列表导入到locustfile中

# creds is created before running locust file and can be stored outside or part of locust # file
creds = [('demo_user1', 'pass1', 'lnla'),
         ('demo_user2', 'pass2', 'taam9'),
         ('demo_user3', 'pass3', 'wevee'),
         ('demo_user4', 'pass4', 'avwew')]

class RegisteredUser(SequentialTaskSet)

    def on_start(self):
        self.credentials = creds.pop()

    @task
    def task_one_name(self):
        task_one_commands

    @task
    def task_two_name(self):
        task_two_commands

    @task
    def stop(self):
        if len(creds) == 0:
            self.user.environment.reached_end = True
            self.user.environment.runner.quit()


class ApiUser(HttpUser):
    tasks = [RegisteredUser]
    host = 'hosturl'
我在任务中使用self.credentials 我在班上创建了stop函数


另外,请注意,RegisteredUser继承自SequentialTaskSet,以按顺序运行所有任务。

我想为10个用户运行,我希望为这10个用户完成10个任务。现在,我想在所有10个用户的所有任务完成后停止蝗虫。我怎样才能做到这一点呢?你可以用蝗虫插件的-I参数来实现:你找到解决这个问题的方法了吗?