Locust is a load testing tool that allows you to script your actions in python (much more pleasant than fiddling with jMeter).
I was investigating an issue that only happened under load (turned out to be due to starvation of the db connection pool). The trouble was, after it had happened, the logs filled up with errors, which weren’t useful information. I wanted the load test to stop, as soon as the first error had occurred.
I couldn’t find anything in the documentation, but a quick nose in the source revealed the existence of a StopLocust exception:
from locust.exception import StopLocust ... response = locust.client.post(uri, data=json.dumps(data), headers=headers) if response.status_code != 200: raise StopLocust()
At any point, you can raise it, and that locust will stop. If you wanted to stop them all, you could set a flag and check it in your other tasks (not ideal, but the best I can offer).
Remember this is undocumented behaviour, and could change at any time, but it works in v0.7.2.