Problem updating Locust script to 1.x: TypeError: __init__() takes 1 positional argument but 2 were given

Problem updating Locust script to 1.x: TypeError: __init__() takes 1 positional argument but 2 were given

已更改(0.x样式)

class MyBaseLocust(Locust):
    def __init__(self):
        super(MyLocust, self).__init__()

到(1.x样式)

class MyBaseUser(User):
    def __init__(self):
        super(MyBaseUser, self).__init__()

我得到:

[2020-07-17 14:16:33,694] XXX/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x28639396378: <lambda>>
Traceback (most recent call last):
...
 in spawn_users
    hatch()
  File "c:\venv\project\lib\site-packages\locust\runners.py", line 165, in hatch
    new_user = user_class(self.environment)
TypeError: __init__() takes 1 positional argument but 2 were given

(这个问题已经被问过几次所以我想我应该在这里添加)

在 1.x

中应该是这样的
class MyBaseUser(HttpUser):
    abstract = True
    def __init__(self, parent):
        super().__init__(parent)

(主要是添加了parent参数,但是需要abstract来避免将基础用户注册为应该执行的东西)