Python蝗虫 - req/task中的自定义超时
我需要使用Locust Lib进行一些负载测试。我要以特定方式处理504-Gateway超时。是否有可能在请求(或任务)中放置自定义超时。我不需要等待120秒直到超时,我需要等待不超过5秒,对我来说是超时。 我的意思是在代码中:
@task(1)
def check_max_5_sec(self):
self.client.get(url=URL_5_sec)
...
@task(1)
def check_max_10_sec(self):
self.client.get(url=URL_10_sec)
在理想的世界中,如果给定超时内没有响应,我希望在蝗虫Web界面上看到故障。 如何实现这一目标?
我知道在fasthttp
中有Connection_timeout
和network_timeout
(可能这可能是解决方案),但是我可以使用httpuser做到这一点
?
I need to run some Load tests with Locust lib. I neeed to to handle 504-gateway timeout in specific way. Is there a possibility to put custom timeout in request (or maybe task). I do not need to wait 120 sec till timeout occurs, I need to wait not wait longer than 5 sec and for me it is timeout.
I mean in code:
@task(1)
def check_max_5_sec(self):
self.client.get(url=URL_5_sec)
...
@task(1)
def check_max_10_sec(self):
self.client.get(url=URL_10_sec)
In ideal world I'd like to see failures on Locust web interface if there is no response within given timeout.
How to achieve this?
I know that in FastHttp
there is connection_timeout
and network_timeout
(probably this might be a solution), but can I do this with HttpUser
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于httpuser/请求,只需通过
timeout = 5
即可。参见 https://docs.pys.python-requests.orgg/en/最新/用户/QuickStart/#超时有关更多信息。
For HttpUser/requests just pass
timeout=5
.See https://docs.python-requests.org/en/latest/user/quickstart/#timeouts for more info.