python - 完成蝗虫实例后是否可以运行代码?
问题描述
假设这是我将在终端中运行的主要文件,即locusts -f main.py
. 在 locust 实例终止或达到时间限制后,是否可以让它也运行代码?可能是清理脚本或发送在某处生成的 csv 报告。
class setup(HttpUser):
wait_time = between(3, 5)
host = 'www.example.com'
tasks = [a, b, c...]
#do something after time limit reached
解决方案
有一个test_stop
事件(https://docs.locust.io/en/stable/extending-locust.html)以及一个quitting
事件(https://docs.locust.io/en/stable/api.html#locust .event.Events.quitting)您可以用于此目的。
推荐阅读
- c# - ASP.NET MVC wrong encoding using ExcelDataReader
- opencv - conda python 3.7 opencv import error libgnutls.so.30: undefined symbol: mpn_add_1, version HOGWEED_4
- xml - 如何使用 maven-xml-plugin 传递 XSLT 参数?
- pycharm - "Indicated packet length too large" error when using remote interpreter in PyCharm
- r - 基于前一列值的起始列行值 - R
- python - 嵌套在字典理解中的列表理解
- python - 意外标记“Hello World!”附近的语法错误 ' 在 Ubuntu 上
- linux - 找出正在运行的 Docker 容器
- flutter - 如何在 Flutter 中制作具有不同功能的可重用容器
- python - 合适的数据类型来保存指向 numpy ndarray 元素的指针