首页 > 解决方案 > 所有用户完成任务后如何停止蝗虫负载测试?

问题描述

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

蝗虫版本:1.1

class RegisteredUser(User):
    @task
    class Forum(TaskSet):
        @task(5)
        def view_thread(self):
            pass

        @task(1)
        def stop(self):
            self.interrupt()

    @task
    def frontpage(self):
        pass

标签: locust

解决方案


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

更多信息:https ://docs.locust.io/en/stable/writing-a-locustfile.html#environment-attribute


推荐阅读