更新时间:2022-04-13 07:30:37
升级了Locust,发现原来的脚本都不可以用,赶紧查询一下发现HttpLocust变成了HttpUser,tasek_set变成了tasks,这也是小CASE,修改后,怎么运行都报错,错误如下:
[2021-10-21 09:06:36,789] bogon/ERROR/locust.user.task: No tasks defined on WebsiteUser. use the @task decorator or set the tasks property of the User (or mark it as abstract = True if you only intend to subclass it) Traceback (most recent call last): File "/Users/crisschan/Library/Python/3.8/lib/python/site-packages/locust/user/task.py", line 291, in run self.schedule_task(self.get_next_task()) File "/Users/crisschan/Library/Python/3.8/lib/python/site-packages/locust/user/task.py", line 423, in get_next_task raise Exception( Exception: No tasks defined on WebsiteUser. use the @task decorator or set the tasks property of the User (or mark it as abstract = True if you only intend to subclass it)
百思不得其解,一个类名的变更为什么出错呢?
后来发现,原来修改完代码没有点击保存,因此每次运行都是保存前的代码,以前用Pycharm都自动保存,VSCode难道就不可以吗?
VSCode当然可以自动保存,进入“file->Preferences->setting->搜索auto save“:
你会发现自动保存有4中模式可选,分别是:
选择每一个在下面都有对应的解释,我更喜欢无论如何你都自动保存(反正有撤销编辑功能),因此我选择了afterDelay的自动保存设置。