Want iteration control and worker shutdown
Prerequisites
- [X] I am using the latest version of Locust
- [X] I am suggesting a new feature, not asking a question
Description
class UserBehavior1(SequentialTaskSet): max_iterations = 2
def on_start(self):
self.iterations = 0 # Initialize the counter in the on_start method
@task
def my_task(self):
if self.iterations >= self.max_iterations:
self.user.environment.runner.stop()
try:
logging.info("hello2")
self.client.get("/time")
self.iterations += 1
except Exception as e:
logging.info(f"Error during request: {e}")
raise RescheduleTaskImmediately
@task
def my_taskA(self):
logging.info("hello1A")
self.user.environment.runner.stop()
`class WebsiteUser(HttpUser):
def on_start(self):
logging.info("thread started--------------------------------------------------------------")
def on_stop(self):
logging.info("thread stoped+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
wait_time = between(1, 5)
tasks = [UserBehavior1]`
' I want to run this in worker node is this possible have ieration control and shutdown of task after 10 iteration. As defining a variable for iteration doesn't got the iteration counter correctly and also many time worker struck to stopped event
Hi! locust-plugins offers something like that: https://github.com/SvenskaSpel/locust-plugins?tab=readme-ov-file#command-line-options
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!