简体   繁体   English

无法在调试模式下运行 locust

[英]Can't run locust in debug mode

Recently I switched from old locust version (0.14.2) to 1.3.1.最近我从旧的 locust 版本(0.14.2)切换到 1.3.1。 Previously I was able to run in debug mode with command WebsiteUser().run() and it stops on all breakpoints.以前,我可以使用命令 WebsiteUser().run() 在调试模式下运行,它会在所有断点处停止。

When I try to run new version with the same command I get next error:当我尝试使用相同的命令运行新版本时,出现下一个错误:

File "/home/user/PycharmProjects/my_test/venv/lib/python3.7/site-packages/locust/user/users.py", line 210, in init super().文件“/home/user/PycharmProjects/my_test/venv/lib/python3.7/site-packages/locust/user/users.py”,第 210 行,在init super() 中。 init (*args, **kwargs) TypeError: init () missing 1 required positional argument: 'environment' init (*args, **kwargs) TypeError: init () 缺少 1 个必需的位置参数:'environment'

I am sure that it's possible to debug new version as previous one, but what I am doing wrong?我确信可以像以前一样调试新版本,但是我做错了什么?

Environment环境

  • OS: Ubuntu 18.04操作系统:Ubuntu 18.04
  • Python version: 3.7.4 Python版本:3.7.4
  • Locust version: 1.3.1蝗虫版本:1.3.1
  • Locust command line that you ran: WebsiteUser().run()您运行的 Locust 命令行:WebsiteUser().run()
  • Locust file contents:蝗虫文件内容:

locustfile.py: locustfile.py:

class UserBehaviour(MyTask):

    @task
    def task_one(self):
        self.action_one()


class WebsiteUser(HttpUser):
    conf = Config()
    host = conf.host
    tasks = [UserBehaviour]
    wait_time = between(0.5, 1.5)

if __name__ == "__main__":
    WebsiteUser().run()

my_task.py:我的_task.py:

class MyTask(BaseTaskSet):

    def action_one(self):
        self.client.get('dummy_path')

Locust 1.0+ has more robust support for using Locust as a library . Locust 1.0+ 对使用 Locust 作为库提供了更强大的支持。 It enables a lot more flexibility and customization in using Locust but there were a number of breaking changes to achieve this (one reason for the 1.0 designation).它在使用 Locust 时实现了更大的灵活性和定制化,但为了实现这一点,有许多重大更改(指定 1.0 的一个原因)。 What you're hitting is Locust now requires an Environment for all Users and associated classes.您遇到的是 Locust 现在需要所有Users和相关类的环境 What you'll probably want to do is:你可能想要做的是:

if __name__ == "__main__":
    from locust.env import Environment
    my_env = Environment(user_classes=[WebsiteUser])
    WebsiteUser(my_env).run()

You are calling你在打电话

class WebsiteUser(HttpUser)

without a HttpUser argument.没有HttpUser参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM