当我运行locust -f /desktop/locustfile.py
时发生以下错误
[2020-06-18 12:09:27,858] fatima/INFO/locust.main: Starting web monitor at *:8089
[2020-06-18 12:09:27,858] fatima/ERROR/stderr: Traceback (most recent call last):
[2020-06-18 12:09:27,858] fatima/ERROR/stderr: File "/home/fatima/.local/bin/locust", line 11, in <module>
[2020-06-18 12:09:27,858] fatima/ERROR/stderr:
[2020-06-18 12:09:27,858] fatima/ERROR/stderr: sys.exit(main())
[2020-06-18 12:09:27,858] fatima/ERROR/stderr: File "/home/fatima/.local/lib/python2.7/site-packages/locust/main.py", line 525, in main
[2020-06-18 12:09:27,858] fatima/ERROR/stderr:
[2020-06-18 12:09:27,858] fatima/ERROR/stderr: gevent.signal(signal.SIGTERM, sig_term_handler)
[2020-06-18 12:09:27,859] fatima/ERROR/stderr: TypeError
[2020-06-18 12:09:27,859] fatima/ERROR/stderr: :
[2020-06-18 12:09:27,859] fatima/ERROR/stderr: 'module' object is not callable
[2020-06-18 12:09:27,859] fatima/ERROR/stderr:
我正在使用python: 3.7, locust 0.13.0 ,这是代码
import random
from locust import HttpLocust, TaskSet, between
products = [
'0PUK6V6EV0',
'1YMWWN1N4O',
'2ZYFJ3GM2N',
'66VCHSJNUP',
'6E92ZMYYFZ',
'9SIQT8TOJO',
'L9ECAV7KIM',
'LS4PSXUNUM',
'OLJCESPC7Z']
def index(l):
l.client.get("/")
def setCurrency(l):
currencies = ['EUR', 'USD', 'JPY', 'CAD']
l.client.post("/setCurrency",
{'currency_code': random.choice(currencies)})
def browseProduct(l):
l.client.get("/product/" + random.choice(products))
class UserBehavior(TaskSet):
def on_start(self):
index(self)
tasks = {index: 1,
setCurrency: 2,
browseProduct: 10,
}
class WebsiteUser(HttpLocust):
task_set = UserBehavior
wait_time = between(1, 10)
我运行 locust 0.13.0 文档示例,它也给了我同样的错误。我认为可能是它的 python 版本问题,所以我安装了 python 2.7 并再次在其上运行 locust 但仍然是同样的错误。