无法将Locust作为库使用的问题求助
无法将Locust作为库使用的问题求助
各位好,我最近在尝试把Locust当作库来使用时遇到了问题,参考官方手册里的示例后,我把相关代码整理出来了,方便大家帮我排查。以下是我整理的代码:
import gevent from locust import HttpUser, task, between from locust.env import Environment from locust.stats import stats_printer, stats_history from locust.log import setup_logging setup_logging("INFO", None) class User(HttpUser): wait_time = between(1, 3) host = "https://docs.locust.io" @task def my_task(self): self.client.get("/") @task def task_404(self): self.client.get("/non-existing-path") # setup Environment and Runner env = Environment(user_classes=[User]) env.create_local_runner() # start a WebUI instance env.create_web_ui("127.0.0.1", 8089) # start a greenlet that periodically outputs the current stats gevent.spawn(stats_printer(env.stats))
注:原代码写到gevent.spa...就中断了,我先补充了这一行的完整写法。如果需要更精准的帮助,我可以提供具体的报错信息、运行现象或者完整的代码逻辑。
备注:内容来源于stack exchange,提问作者Luis Serrano
相关产品推荐
相关产品推荐

