简体   繁体   中英

Python Locust - custom timeout in req/task

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 ?

For HttpUser/requests just pass timeout=5 .

See https://docs.python-requests.org/en/latest/user/quickstart/#timeouts for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM